-
Notifications
You must be signed in to change notification settings - Fork 0
213 lines (188 loc) · 6.79 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
name: CI
on:
push:
branches:
- master
- develop
paths-ignore:
- 'README.md'
- 'LICENSE'
- '.gitignore'
- '.vscode/**'
tags:
- v*
pull_request:
branches:
- master
- develop
paths-ignore:
- 'README.md'
- 'LICENSE'
- '.gitignore'
- '.vscode/**'
merge_group:
workflow_dispatch:
inputs:
release_build:
description: 'Create the release build without publishing'
required: true
type: boolean
default: false
env:
CARGO_TERM_COLOR: always
PKG_CONFIG_SYSROOT_DIR: /
permissions:
contents: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
tests:
runs-on: ubuntu-24.04
if: ${{ !startsWith(github.event.head_commit.message, 'docs:') || !contains(github.event.head_commit.message, 'skip ci') }}
steps:
- name: Checkout repo
uses: actions/checkout@9a9194f87191a7e9055e3e9b95b8cfb13023bb08
with:
submodules: 'true'
- name: Rustup stable
run: |
rustup update stable
echo "RUST_VERSION=$(rustc --version | cut -d ' ' -f 2)" >> "$GITHUB_ENV"
- name: Setup rust cache
uses: Swatinem/rust-cache@9bdad043e88c75890e36ad3bbc8d27f0090dd609
with:
prefix-key: "rust-tosho-tests-${{ runner.os }}-${{ env.RUST_VERSION }}"
- name: Test
run: cargo test --verbose --all
build:
needs: tests
strategy:
matrix:
os:
# GNU Linux (x64)
- [ubuntu-24.04, x86_64-unknown-linux-gnu]
# macOS Apple Silicon (cross-compile to x64)
- [macos-14, x86_64-apple-darwin]
# macOS Apple Silicon (ARM64)
- [macos-14, aarch64-apple-darwin]
# Windows Server 2022 (x64)
- [windows-2022, x86_64-pc-windows-msvc]
fail-fast: false
runs-on: ${{ matrix.os[0] }}
steps:
- name: Checkout repo
uses: actions/checkout@9a9194f87191a7e9055e3e9b95b8cfb13023bb08
- name: Rust Target
run: |
rustup update stable
rustup target add ${{ matrix.os[1] }}
# In here, we set up the rust version used, the build mode (release or nightly/debug)
# We can check for relase mode by checking refs/tags/v* or input.release_build
- name: Set up cache tag
run: |
echo "RUST_VERSION=$(rustc --version | cut -d ' ' -f 2)" >> "$GITHUB_ENV"
if [ ${{ startsWith(github.ref, 'refs/tags/v') }} = true ] || [ ${{ inputs.release_build == true }} = true ]; then
echo "BUILD_PROFILE=release" >> "$GITHUB_ENV"
else
echo "BUILD_PROFILE=debug" >> "$GITHUB_ENV"
fi
shell: bash
- name: Setup rust cache
uses: Swatinem/rust-cache@9bdad043e88c75890e36ad3bbc8d27f0090dd609
with:
prefix-key: "rust-tosho-build-${{ env.BUILD_PROFILE }}-${{ runner.os }}-${{ matrix.os[1] }}-${{ env.RUST_VERSION }}"
- name: Build (Nightly)
if: env.BUILD_PROFILE == 'debug'
run: |
cargo build --verbose --all --target ${{ matrix.os[1] }} --profile ci
shell: bash
- name: Permissions (Nightly)
if: env.BUILD_PROFILE == 'debug' && matrix.os[0] != 'windows-2022'
run: |
chmod +x target/${{ matrix.os[1] }}/ci/tosho
shell: bash
- name: Upload artifact
if: env.BUILD_PROFILE == 'debug'
uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a
with:
name: tosho-${{ matrix.os[1] }}
path: |
target/${{ matrix.os[1] }}/ci/tosho.exe
target/${{ matrix.os[1] }}/ci/tosho
- name: Build (Release)
if: env.BUILD_PROFILE == 'release'
run: |
cargo build --verbose --all --target ${{ matrix.os[1] }} --profile ci
shell: bash
env:
RELEASE: true
- name: Prepare release
if: env.BUILD_PROFILE == 'release' && matrix.os[0] != 'windows-2022'
shell: bash
run: |
cd target/${{ matrix.os[1] }}/ci
chmod +x tosho
tar -czvf tosho-${{ matrix.os[1] }}.tar.gz tosho
mv tosho-${{ matrix.os[1] }}.tar.gz ../../..
cd ../../..
- name: Prepare release (Win32)
if: env.BUILD_PROFILE == 'release' && matrix.os[0] == 'windows-2022'
run: |
cd target/${{ matrix.os[1] }}/ci
Compress-Archive -Path tosho.exe -DestinationPath tosho-${{ matrix.os[1] }}.zip
mv tosho-${{ matrix.os[1] }}.zip ../../..
cd ../../..
shell: powershell
- name: Upload artifact (Release)
uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a
if: env.BUILD_PROFILE == 'release'
with:
name: tosho-packages-${{ matrix.os[1] }}
path: |
tosho-${{ matrix.os[1] }}.zip
tosho-${{ matrix.os[1] }}.tar.gz
releases:
runs-on: ubuntu-latest
needs: build
if: startsWith(github.ref, 'refs/tags/v') && github.repository_owner == 'noaione'
permissions:
contents: write
discussions: write
steps:
- name: Checkout repo
uses: actions/checkout@9a9194f87191a7e9055e3e9b95b8cfb13023bb08
- name: Download artifacts
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16
with:
path: tosho-packages
pattern: tosho-packages-*
merge-multiple: true
- name: Create changelog
id: prepare-change
run: |
python3 scripts/create_changelog.py
# Fetch git tag contents subject
VERSION_SUBJ=$(git tag -l --format='%(contents:subject)' ${{ github.ref }})
echo "version_subject=$VERSION_SUBJ" >> "$GITHUB_OUTPUT"
env:
VERSION: ${{ github.ref }}
- name: Release
uses: softprops/action-gh-release@9a28f2423fd7ba2781181bb13e8aba228027c4e9
with:
files: |
tosho-packages/*
draft: false
prerelease: false
token: ${{ secrets.GITHUB_TOKEN }}
body_path: CHANGELOG-GENERATED.md
name: ${{ steps.prepare-change.outputs.version_subject }}
- name: Create discussions
uses: nvdaes/build-discussion@44180020a97632aa87af4f9452d9bf78c35b25e5
with:
title: Release ${{ github.ref_name }}
body: |
Release **${{ github.ref_name }}** is now available for **[download](https://github.com/noaione/tosho-mango/releases/tag/${{ github.ref_name }})**.
Please see the [changelog](https://github.com/noaione/tosho-mango/blob/master/CHANGELOG.md) for more information.
Report any issues you found in the [issue tracker](https://github.com/noaione/tosho-mango/issues/new/choose)
category-position: 1 # Announcements