-
Notifications
You must be signed in to change notification settings - Fork 2
220 lines (191 loc) · 7.28 KB
/
release.yml
File metadata and controls
220 lines (191 loc) · 7.28 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
name: Release
on:
push:
tags:
- 'v*'
jobs:
prepare:
name: Prepare Version
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
new_version: ${{ steps.bump.outputs.new_version }}
version_only: ${{ steps.bump.outputs.version_only }}
sha: ${{ steps.commit.outputs.sha }}
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Calculate Version
id: bump
run: |
NEW_VERSION="${{ github.ref_name }}"
VERSION_ONLY="${NEW_VERSION#v}"
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
echo "version_only=$VERSION_ONLY" >> $GITHUB_OUTPUT
- name: Update Cargo.toml
run: |
VERSION="${{ steps.bump.outputs.version_only }}"
awk '/^\[package\]/ {print; p=1; next} p && /^version =/ {print "version = \"'$VERSION'\""; p=0; next} {print}' Cargo.toml > Cargo.toml.tmp && mv Cargo.toml.tmp Cargo.toml
cargo update --workspace
- name: Commit and Push
id: commit
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add Cargo.toml Cargo.lock
if [ -z "$(git status --porcelain)" ]; then
echo "nothing to commit"
else
git commit -m "chore: bump version to ${{ steps.bump.outputs.new_version }}"
git push origin HEAD:master
fi
echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
build:
name: Build (${{ matrix.suffix }})
needs: prepare
runs-on: ubuntu-latest
permissions:
contents: read
actions: read
id-token: none
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
cpu: generic
suffix: x86_64
- target: x86_64-unknown-linux-gnu
cpu: x86-64-v3
suffix: x86_64-v3
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
ref: ${{ needs.prepare.outputs.sha }}
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y libgtk-4-dev libvte-2.91-gtk4-dev
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Rust Cache
uses: Swatinem/rust-cache@v2
- name: Build (Performance optimized)
run: |
export RUSTFLAGS="-C target-cpu=${{ matrix.cpu }}"
if [ "${{ matrix.cpu }}" = "generic" ]; then export RUSTFLAGS=""; fi
cargo build --release --target ${{ matrix.target }}
- name: Prepare binary
run: |
cd target/${{ matrix.target }}/release
strip rustmius || true
mv rustmius rustmius-${{ matrix.suffix }}
- name: Upload Artifact
uses: actions/upload-artifact@v7
with:
name: binary-${{ matrix.suffix }}
path: target/${{ matrix.target }}/release/rustmius-${{ matrix.suffix }}
release:
name: Create Release
needs: [prepare, build]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download Artifacts
uses: actions/download-artifact@v8
with:
path: artifacts
pattern: binary-*
merge-multiple: true
- name: Release
uses: softprops/action-gh-release@v3
with:
tag_name: ${{ needs.prepare.outputs.new_version }}
target_commitish: ${{ needs.prepare.outputs.sha }}
files: artifacts/rustmius-*
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
aur:
name: Update AUR (${{ matrix.package }})
needs: [prepare, build]
runs-on: ubuntu-latest
permissions:
contents: write
strategy:
matrix:
package: [rustmius, rustmius-bin]
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Download Artifacts
if: matrix.package == 'rustmius-bin'
uses: actions/download-artifact@v8
with:
name: binary-x86_64
path: .
- name: Update PKGBUILD (rustmius-bin)
if: matrix.package == 'rustmius-bin'
run: |
VERSION="${{ needs.prepare.outputs.version_only }}"
# Paths updated to packages/ subdirectory
HASH_DESKTOP=$(sha256sum packages/org.rustmius.Rustmius.desktop | cut -d' ' -f1)
HASH_PNG=$(sha256sum packages/rustmius.png | cut -d' ' -f1)
HASH_LICENSE=$(sha256sum LICENSE | cut -d' ' -f1)
HASH_BINARY=$(sha256sum rustmius-x86_64 | cut -d' ' -f1)
# Target the specific PKGBUILD in packages/rustmius-bin/
TARGET="packages/rustmius-bin/PKGBUILD"
awk -v v="$VERSION" -v d="$HASH_DESKTOP" -v p="$HASH_PNG" -v l="$HASH_LICENSE" -v b="$HASH_BINARY" '
BEGIN { h[0]=d; h[1]=p; h[2]=l; h[3]=b; i=0 }
/^pkgver=/ { $0="pkgver=" v }
/^pkgrel=/ { $0="pkgrel=1" }
/^pkgdesc=/ { $0="pkgdesc=\"Full local Termius alternative for Linux (GTK4) - binary release\"" }
/'\''[0-9a-f]{64}'\''/ && i < 4 {
sub(/'\''[0-9a-f]{64}'\''/, "'\''" h[i++] "'\''")
}
{ print }
' "$TARGET" > "$TARGET.tmp" && mv "$TARGET.tmp" "$TARGET"
- name: Update PKGBUILD (rustmius)
if: matrix.package == 'rustmius'
run: |
VERSION="${{ needs.prepare.outputs.version_only }}"
# Get source archive hash
URL="https://github.com/Cleboost/Rustmius/archive/v$VERSION.tar.gz"
curl -L -o source.tar.gz "$URL"
HASH_SOURCE=$(sha256sum source.tar.gz | cut -d' ' -f1)
TARGET="packages/rustmius/PKGBUILD"
sed -i "s/^pkgver=.*/pkgver=$VERSION/" "$TARGET"
sed -i "s/^pkgrel=.*/pkgrel=1/" "$TARGET"
sed -i "s/^pkgdesc=.*/pkgdesc=\"Full local Termius alternative for Linux (GTK4) - built from stable source\"/" "$TARGET"
# Update the source hash (it's the only hash in this PKGBUILD)
sed -i "s/sha256sums=('.*')/sha256sums=('$HASH_SOURCE')/" "$TARGET"
- name: Commit and Push PKGBUILDs
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add packages/
if [ -z "$(git status --porcelain)" ]; then
echo "nothing to commit"
else
git commit -m "chore: update PKGBUILDs to ${{ needs.prepare.outputs.new_version }}"
git pull --rebase origin master
git push origin HEAD:master
fi
- name: Publish AUR package
uses: KSXGitHub/github-actions-deploy-aur@v4.1.3
with:
pkgname: ${{ matrix.package }}
pkgbuild: ./packages/${{ matrix.package }}/PKGBUILD
commit_username: ${{ secrets.AUR_USERNAME }}
commit_email: ${{ secrets.AUR_EMAIL }}
ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
commit_message: "Update to ${{ needs.prepare.outputs.new_version }}"
ssh_keyscan_types: rsa,ecdsa,ed25519