-
Notifications
You must be signed in to change notification settings - Fork 0
239 lines (235 loc) · 9.9 KB
/
publish.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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
name: Publish
on:
workflow_dispatch:
inputs:
versionType:
type: choice
description: "<major|minor|patch>"
required: true
default: "patch"
options:
- major
- minor
- patch
permissions:
contents: write
discussions: write
jobs:
publish:
name: Publish ${{ inputs.versionType }} release
outputs:
version: ${{ steps.update-version.outputs.version }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- run: rustup toolchain install nightly --profile minimal --component clippy rustfmt && rustup default nightly && cargo install cargo-edit
name: Install Rust nightly toolchain
- name: Install git-cliff
uses: taiki-e/install-action@git-cliff
- uses: Swatinem/rust-cache@v2
name: Setup Rust cache
with:
shared-key: ${{ runner.os }}-ci
save-if: ${{ github.ref == 'refs/heads/main' }}
- id: update-version
shell: bash
name: Bump version
# Use npm because yarn is for some reason not able to output only the version name
run: |
cargo set-version --workspace --bump ${{ inputs.versionType }}
chmod +x .github/scripts/get-version.rs
VERSION=$(.github/scripts/get-version.rs --path ./nyanpasu_service/Cargo.toml | head -n 1)
echo "$VERSION"
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Generate a changelog for the new version
shell: bash
id: build-changelog
run: |
touch /tmp/changelog.md
git-cliff --config cliff.toml --verbose --strip header --unreleased --tag v${{ steps.update-version.outputs.version }} > /tmp/changelog.md
if [ $? -eq 0 ]; then
CONTENT=$(cat /tmp/changelog.md)
cat /tmp/changelog.md | cat - ./CHANGELOGS.md > temp && mv temp ./CHANGELOGS.md
{
echo 'content<<EOF'
echo "$CONTENT"
echo EOF
} >> $GITHUB_OUTPUT
echo "version=${{ steps.update-version.outputs.version }}" >> $GITHUB_OUTPUT
else
echo "Failed to generate changelog"
exit 1
fi
env:
GITHUB_REPO: ${{ github.repository }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "chore: bump version to v${{ steps.update-version.outputs.version }}"
commit_user_name: "github-actions[bot]"
commit_user_email: "41898282+github-actions[bot]@users.noreply.github.com"
tagging_message: "v${{ steps.update-version.outputs.version }}"
- name: Release
uses: softprops/action-gh-release@v2
with:
# draft: true
body: ${{steps.build-changelog.outputs.content}}
name: Nyanpasu Service v${{steps.update-version.outputs.version}}
tag_name: "v${{ steps.update-version.outputs.version }}"
# target_commitish: ${{ steps.tag.outputs.sha }}
release_macos:
needs: [publish]
name: Release v${{ needs.publish.outputs.version }} for macOS
strategy:
matrix:
profile:
- os: macos-latest
target: x86_64-apple-darwin
- os: macos-latest
target: aarch64-apple-darwin
runs-on: ${{ matrix.profile.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
ref: v${{ needs.publish.outputs.version }}
- name: Install coreutils for macOS
run: brew install coreutils
- name: Install Rust toolchain and target toolchain
run: rustup toolchain install nightly --profile minimal && rustup target add ${{ matrix.profile.target }} --toolchain nightly
- name: Build
run: cargo +nightly build --release --target ${{ matrix.profile.target }}
- name: Archive
run: |
mkdir -p target/release
cp target/${{ matrix.profile.target }}/release/nyanpasu-service target/release/nyanpasu-service
cd target/release
tar -czf nyanpasu-service-${{ matrix.profile.target }}.tar.gz ./nyanpasu-service
cd ../..
mv target/release/nyanpasu-service-${{ matrix.profile.target }}.tar.gz .
- name: Calc the archive signature
run: sha256sum nyanpasu-service-${{ matrix.profile.target }}.tar.gz > nyanpasu-service-${{ matrix.profile.target }}.tar.gz.sha256
- name: Upload Release Asset
uses: softprops/action-gh-release@v2
with:
tag_name: "v${{ needs.publish.outputs.version }}"
files: |
nyanpasu-service-${{ matrix.profile.target }}.tar.gz
nyanpasu-service-${{ matrix.profile.target }}.tar.gz.sha256
release_linux:
needs: [publish]
name: Release v${{ needs.publish.outputs.version }} for ${{ matrix.profile.target }}
strategy:
matrix:
profile:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
- os: ubuntu-latest
target: i686-unknown-linux-gnu
- os: ubuntu-latest
target: i686-unknown-linux-musl
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
- os: ubuntu-latest
target: aarch64-unknown-linux-musl
- os: ubuntu-latest
target: armv7-unknown-linux-gnueabi
- os: ubuntu-latest
target: armv7-unknown-linux-musleabi
- os: ubuntu-latest
target: armv7-unknown-linux-musleabihf
- os: ubuntu-latest
target: armv7-unknown-linux-gnueabihf
runs-on: ${{ matrix.profile.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
ref: v${{ needs.publish.outputs.version }}
- name: Install Rust toolchain and target toolchain
run: rustup toolchain install nightly --profile minimal && rustup target add ${{ matrix.profile.target }} --toolchain nightly
- name: Setup Cross
if: contains(matrix.profile.target, 'musl')
run: |
curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
cargo binstall cross -y
- uses: goto-bus-stop/setup-zig@v2
name: Setup Zig
if: contains(matrix.profile.target, 'musl') == false
- name: Setup Cargo zigbuild
if: contains(matrix.profile.target, 'musl') == false
run: |
curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
cargo binstall cargo-zigbuild -y
- name: Build
if: contains(matrix.profile.target, 'musl') == false
run: cargo +nightly zigbuild --release --target ${{ matrix.profile.target }}
- name: Build with Cross
if: contains(matrix.profile.target, 'musl')
run: cross +nightly build --release --target ${{ matrix.profile.target }}
- name: Archive
run: |
mkdir -p target/release
cp target/${{ matrix.profile.target }}/release/nyanpasu-service target/release/nyanpasu-service
cd target/release
tar -czf nyanpasu-service-${{ matrix.profile.target }}.tar.gz ./nyanpasu-service
cd ../..
mv target/release/nyanpasu-service-${{ matrix.profile.target }}.tar.gz .
- name: Calc the archive signature
run: sha256sum nyanpasu-service-${{ matrix.profile.target }}.tar.gz > nyanpasu-service-${{ matrix.profile.target }}.tar.gz.sha256
- name: Upload Release Asset
uses: softprops/action-gh-release@v2
with:
tag_name: "v${{ needs.publish.outputs.version }}"
files: |
nyanpasu-service-${{ matrix.profile.target }}.tar.gz
nyanpasu-service-${{ matrix.profile.target }}.tar.gz.sha256
release_windows:
needs: [publish]
name: Release v${{ needs.publish.outputs.version }} for ${{ matrix.profile.target }}
strategy:
matrix:
profile:
- os: windows-latest
target: x86_64-pc-windows-msvc
- os: windows-latest
target: aarch64-pc-windows-msvc
- os: windows-latest
target: i686-pc-windows-msvc
runs-on: ${{ matrix.profile.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
ref: v${{ needs.publish.outputs.version }}
- name: Install Rust toolchain and target toolchain
run: rustup toolchain install nightly --profile minimal && rustup target add ${{ matrix.profile.target }} --toolchain nightly
- name: Build
run: cargo +nightly build --release --target ${{ matrix.profile.target }}
- name: Archive
run: |
New-Item -ItemType Directory -Force -Path target\release
Copy-Item target\${{ matrix.profile.target }}\release\nyanpasu-service.exe target\release\nyanpasu-service.exe
Set-Location target\release
Compress-Archive -Path nyanpasu-service.exe -DestinationPath ..\..\nyanpasu-service-${{ matrix.profile.target }}.zip
Set-Location ..\..
- name: Calc the archive signature
shell: pwsh
run: Get-FileHash nyanpasu-service-${{ matrix.profile.target }}.zip -Algorithm SHA256 | Format-List > nyanpasu-service-${{ matrix.profile.target }}.zip.sha256
- name: Upload Release Asset
uses: softprops/action-gh-release@v2
with:
tag_name: "v${{ needs.publish.outputs.version }}"
files: |
nyanpasu-service-${{ matrix.profile.target }}.zip
nyanpasu-service-${{ matrix.profile.target }}.zip.sha256