-
Notifications
You must be signed in to change notification settings - Fork 1
222 lines (195 loc) · 6.93 KB
/
release.yml
File metadata and controls
222 lines (195 loc) · 6.93 KB
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
name: Release
on:
workflow_dispatch:
inputs:
tag:
description: 'Release tag (e.g., v1.0.0)'
required: true
type: string
prerelease:
description: 'Mark as prerelease'
required: false
default: false
type: boolean
workflow_call:
inputs:
tag:
description: 'Release tag (e.g., v1.0.0)'
required: false
type: string
prerelease:
description: 'Mark as prerelease'
required: false
default: false
type: boolean
outputs:
release_url:
description: 'URL of the created release'
value: ${{ jobs.create-release.outputs.release_url }}
env:
CARGO_TERM_COLOR: always
concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: false
jobs:
build-release:
name: Build Release Artifacts
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
artifact_name: rustirc
asset_name: rustirc-linux-amd64
compress: tar.gz
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
artifact_name: rustirc
asset_name: rustirc-linux-arm64
compress: tar.gz
- os: windows-latest
target: x86_64-pc-windows-msvc
artifact_name: rustirc.exe
asset_name: rustirc-windows-amd64.exe
compress: zip
# DISABLED: macOS builds removed
# - os: macos-latest
# target: x86_64-apple-darwin
# artifact_name: rustirc
# asset_name: rustirc-macos-amd64
# compress: tar.gz
# - os: macos-latest
# target: aarch64-apple-darwin
# artifact_name: rustirc
# asset_name: rustirc-macos-arm64
# compress: tar.gz
runs-on: ${{ matrix.os }}
permissions:
contents: read
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
with:
key: release-${{ matrix.target }}
- name: Install cross-compilation tools (Linux ARM64)
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
- name: Build release binary
run: cargo build --release --target ${{ matrix.target }} --bin rustirc
- name: Compress artifact (Unix)
if: matrix.compress == 'tar.gz'
run: |
cd target/${{ matrix.target }}/release
tar -czf ${{ matrix.asset_name }}.tar.gz ${{ matrix.artifact_name }}
echo "ASSET_PATH=target/${{ matrix.target }}/release/${{ matrix.asset_name }}.tar.gz" >> $GITHUB_ENV
echo "ASSET_NAME=${{ matrix.asset_name }}.tar.gz" >> $GITHUB_ENV
- name: Compress artifact (Windows)
if: matrix.compress == 'zip'
run: |
cd target/${{ matrix.target }}/release
7z a ${{ matrix.asset_name }}.zip ${{ matrix.artifact_name }}
echo "ASSET_PATH=target/${{ matrix.target }}/release/${{ matrix.asset_name }}.zip" >> $GITHUB_ENV
echo "ASSET_NAME=${{ matrix.asset_name }}.zip" >> $GITHUB_ENV
shell: pwsh
- name: Generate checksums
run: |
if [ "${{ runner.os }}" = "Windows" ]; then
certutil -hashfile "$ASSET_PATH" SHA256 | findstr /v "hash" | findstr /v "CertUtil" > "$ASSET_PATH.sha256"
else
shasum -a 256 "$ASSET_PATH" > "$ASSET_PATH.sha256"
fi
shell: bash
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: ${{ matrix.asset_name }}
path: |
${{ env.ASSET_PATH }}
${{ env.ASSET_PATH }}.sha256
retention-days: 30
create-release:
name: Create Release
needs: build-release
runs-on: ubuntu-latest
outputs:
release_url: ${{ steps.create_release.outputs.html_url }}
permissions:
contents: write
discussions: write
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Download all artifacts
uses: actions/download-artifact@v8
with:
path: artifacts
- name: Set release variables
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "TAG_NAME=${{ inputs.tag }}" >> $GITHUB_ENV
echo "PRERELEASE=${{ inputs.prerelease }}" >> $GITHUB_ENV
else
echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
echo "PRERELEASE=false" >> $GITHUB_ENV
fi
- name: Check if release exists
id: check_release
run: |
if gh release view "$TAG_NAME" >/dev/null 2>&1; then
echo "exists=true" >> $GITHUB_OUTPUT
echo "Release $TAG_NAME already exists"
else
echo "exists=false" >> $GITHUB_OUTPUT
echo "Release $TAG_NAME does not exist"
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Generate changelog
if: steps.check_release.outputs.exists == 'false'
run: |
cat > release_notes.md << 'EOF'
## Release ${{ env.TAG_NAME }}
### Downloads
Choose the appropriate binary for your platform:
- **Linux x86_64**: `rustirc-linux-amd64.tar.gz`
- **Linux ARM64**: `rustirc-linux-arm64.tar.gz`
- **Windows x86_64**: `rustirc-windows-amd64.exe.zip`
### Verification
All binaries include SHA256 checksums for verification.
### Installation
1. Download the appropriate binary for your platform
2. Extract the archive (except Windows .exe.zip)
3. Make the binary executable: `chmod +x rustirc` (Unix/Linux/macOS)
4. Run the client: `./rustirc`
For detailed installation and usage instructions, see the [README](https://github.com/doublegate/RustIRC#readme).
EOF
- name: Create new release
id: create_release
if: steps.check_release.outputs.exists == 'false'
run: |
release_output=$(gh release create "$TAG_NAME" \
--title "RustIRC $TAG_NAME" \
--notes-file release_notes.md \
${{ env.PRERELEASE == 'true' && '--prerelease' || '' }} \
--generate-notes \
--json html_url \
--jq .html_url)
echo "html_url=$release_output" >> $GITHUB_OUTPUT
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload release assets
run: |
# Find and upload all artifacts
find artifacts -type f \( -name "*.tar.gz" -o -name "*.zip" -o -name "*.sha256" \) -exec gh release upload "$TAG_NAME" {} --clobber \;
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}