-
Notifications
You must be signed in to change notification settings - Fork 2
191 lines (169 loc) · 6.12 KB
/
release.yml
File metadata and controls
191 lines (169 loc) · 6.12 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
name: Release
on:
push:
branches: [main]
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
jobs:
check:
name: Check for release
runs-on: ubuntu-latest
outputs:
released: ${{ steps.boop.outputs.released }}
version: ${{ steps.boop.outputs.version }}
changelog: ${{ steps.boop.outputs.changelog }}
sha: ${{ steps.release.outputs.sha }}
steps:
- uses: actions/checkout@v4
- name: Run boop
id: boop
uses: danielkov/boop@v1
- name: Update Cargo.toml and tag
id: release
if: steps.boop.outputs.released == 'true'
run: |
VERSION="${{ steps.boop.outputs.version }}"
# Install Rust for cargo update
rustup default stable
# Update workspace version in Cargo.toml
sed -i "s/^version = \"[0-9]*\.[0-9]*\.[0-9]*\"/version = \"$VERSION\"/" Cargo.toml
cargo update --workspace
# Commit and tag
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add .boop/releases.toml Cargo.toml Cargo.lock
cat > /tmp/commit-msg.txt <<'COMMIT_MSG'
ci(boop): release ${{ steps.boop.outputs.version }} [skip ci]
${{ steps.boop.outputs.changelog }}
COMMIT_MSG
git commit -F /tmp/commit-msg.txt
git tag "v$VERSION"
git push origin main --follow-tags
echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
build:
name: Build ${{ matrix.target }}
needs: [check]
if: needs.check.outputs.released == 'true'
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# macOS
- target: x86_64-apple-darwin
os: macos-latest
archive: tar.gz
- target: aarch64-apple-darwin
os: macos-latest
archive: tar.gz
# Linux
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
archive: tar.gz
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
archive: tar.gz
cross: true
# Windows
- target: x86_64-pc-windows-msvc
os: windows-latest
archive: zip
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ needs.check.outputs.sha }}
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install system dependencies (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y libxkbcommon-dev libwayland-dev libvulkan-dev pkg-config
- name: Install cross-compilation tools
if: matrix.cross
uses: taiki-e/setup-cross-toolchain-action@v1
with:
target: ${{ matrix.target }}
- name: Build
run: cargo build --workspace --release --target ${{ matrix.target }}
- name: Create Silo.app bundle
if: runner.os == 'macOS'
run: |
mkdir -p Silo.app/Contents/MacOS Silo.app/Contents/Resources
cp target/${{ matrix.target }}/release/silo Silo.app/Contents/MacOS/Silo
cp crates/silo/resources/AppIcon.icns Silo.app/Contents/Resources/AppIcon.icns
VERSION="${{ needs.check.outputs.version }}"
cat > Silo.app/Contents/Info.plist << PLIST
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleName</key><string>Silo</string>
<key>CFBundleDisplayName</key><string>Silo</string>
<key>CFBundleExecutable</key><string>Silo</string>
<key>CFBundleIdentifier</key><string>com.granary.silo</string>
<key>CFBundleVersion</key><string>$VERSION</string>
<key>CFBundleShortVersionString</key><string>$VERSION</string>
<key>CFBundlePackageType</key><string>APPL</string>
<key>CFBundleIconFile</key><string>AppIcon</string>
<key>NSHighResolutionCapable</key><true/>
</dict>
</plist>
PLIST
- name: Package (Unix)
if: matrix.os != 'windows-latest'
run: |
cd target/${{ matrix.target }}/release
if [ -d ../../../Silo.app ]; then
tar -czvf ../../../granary-${{ matrix.target }}.tar.gz granary granaryd silo -C ../../.. Silo.app
else
tar -czvf ../../../granary-${{ matrix.target }}.tar.gz granary granaryd silo
fi
cd ../../..
- name: Package (Windows)
if: matrix.os == 'windows-latest'
run: |
cd target/${{ matrix.target }}/release
7z a ../../../granary-${{ matrix.target }}.zip granary.exe granaryd.exe silo.exe
cd ../../..
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: granary-${{ matrix.target }}
path: granary-${{ matrix.target }}.${{ matrix.archive }}
release:
name: Create Release
needs: [check, build]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Prepare release files
run: |
mkdir -p release
find artifacts -type f \( -name "*.tar.gz" -o -name "*.zip" \) -exec mv {} release/ \;
ls -la release/
- name: Generate checksums
run: |
cd release
sha256sum * > checksums.sha256
cat checksums.sha256
- name: Create Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ needs.check.outputs.version }}
name: v${{ needs.check.outputs.version }}
body: ${{ needs.check.outputs.changelog }}
files: |
release/*
draft: false
prerelease: ${{ contains(needs.check.outputs.version, '-') }}