-
Notifications
You must be signed in to change notification settings - Fork 4
149 lines (142 loc) · 5.8 KB
/
release.yml
File metadata and controls
149 lines (142 loc) · 5.8 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
name: Release
on:
push:
tags: ['v*']
workflow_dispatch:
jobs:
# ── Build platform binaries ──────────────────────────────────────────────
build-macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Add targets
run: rustup target add aarch64-apple-darwin x86_64-apple-darwin
- name: Build ARM64
run: cargo build --release --target aarch64-apple-darwin
- name: Build x86_64
run: cargo build --release --target x86_64-apple-darwin
- name: Create universal binary
run: |
lipo -create \
target/aarch64-apple-darwin/release/squeez \
target/x86_64-apple-darwin/release/squeez \
-output squeez-macos-universal
- uses: actions/upload-artifact@v4
with:
name: squeez-macos-universal
path: squeez-macos-universal
build-linux-x86_64:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Add target
run: rustup target add x86_64-unknown-linux-musl
- name: Install musl-tools
run: sudo apt-get update && sudo apt-get install -y musl-tools
- name: Build
run: cargo build --release --target x86_64-unknown-linux-musl
- run: mv target/x86_64-unknown-linux-musl/release/squeez squeez-linux-x86_64
- uses: actions/upload-artifact@v4
with:
name: squeez-linux-x86_64
path: squeez-linux-x86_64
build-linux-aarch64:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Install cross
run: cargo install cross
- name: Build
run: cross build --release --target aarch64-unknown-linux-musl
- run: mv target/aarch64-unknown-linux-musl/release/squeez squeez-linux-aarch64
- uses: actions/upload-artifact@v4
with:
name: squeez-linux-aarch64
path: squeez-linux-aarch64
build-windows-x86_64:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Build
run: cargo build --release --target x86_64-pc-windows-msvc
- run: mv target/x86_64-pc-windows-msvc/release/squeez.exe squeez-windows-x86_64.exe
- uses: actions/upload-artifact@v4
with:
name: squeez-windows-x86_64
path: squeez-windows-x86_64.exe
# ── GitHub Release (binaries + checksums) ────────────────────────────────
# Only ONE release is kept at all times — the latest.
# All previous releases (different tag) are deleted after publishing.
release:
needs: [build-macos, build-linux-x86_64, build-linux-aarch64, build-windows-x86_64]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
- name: Generate checksums
run: |
cd squeez-macos-universal && sha256sum squeez-macos-universal > ../checksums.sha256 && cd ..
cd squeez-linux-x86_64 && sha256sum squeez-linux-x86_64 >> ../checksums.sha256 && cd ..
cd squeez-linux-aarch64 && sha256sum squeez-linux-aarch64 >> ../checksums.sha256 && cd ..
cd squeez-windows-x86_64 && sha256sum squeez-windows-x86_64.exe >> ../checksums.sha256 && cd ..
- name: Upload to GitHub release
uses: softprops/action-gh-release@v1
with:
files: |
squeez-macos-universal/squeez-macos-universal
squeez-linux-x86_64/squeez-linux-x86_64
squeez-linux-aarch64/squeez-linux-aarch64
squeez-windows-x86_64/squeez-windows-x86_64.exe
checksums.sha256
make_latest: true
- name: Delete previous releases (keep only latest)
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
CURRENT_TAG="${{ github.ref_name }}"
gh release list --limit 100 --json tagName -q '.[].tagName' | while read TAG; do
if [ "$TAG" != "$CURRENT_TAG" ]; then
echo "Deleting old release: $TAG"
gh release delete "$TAG" --yes --cleanup-tag 2>/dev/null || true
fi
done
# ── npm publish ──────────────────────────────────────────────────────────
publish-npm:
needs: release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'
- name: Sync version from git tag
run: |
VERSION="${GITHUB_REF_NAME#v}"
cd npm
node -e "
const fs = require('fs');
const p = JSON.parse(fs.readFileSync('package.json','utf8'));
p.version = '$VERSION';
fs.writeFileSync('package.json', JSON.stringify(p, null, 2) + '\n');
"
echo "Publishing squeez@$VERSION to npm"
- name: Publish
run: cd npm && npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
# ── crates.io publish ────────────────────────────────────────────────────
publish-crates:
needs: release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Publish to crates.io
run: cargo publish --no-verify --token ${{ secrets.CARGO_REGISTRY_TOKEN }}