-
Notifications
You must be signed in to change notification settings - Fork 0
186 lines (165 loc) · 6.35 KB
/
dev-release.yml
File metadata and controls
186 lines (165 loc) · 6.35 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
name: Dev Release
on:
workflow_call:
inputs:
binary-name:
description: "Name of the output binary"
type: string
required: true
package-name:
description: "Cargo package name (-p flag)"
type: string
required: true
ci-workflow-name:
description: "Name of the CI workflow to wait on"
type: string
default: "CI"
extra-files:
description: "Space-separated list of extra files to include in archive"
type: string
default: ""
permissions:
contents: write
concurrency:
group: dev-release
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
jobs:
dev-release:
name: Dev Release (${{ matrix.target }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
archive: tar.gz
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
archive: tar.gz
- target: x86_64-pc-windows-msvc
os: windows-latest
archive: zip
- target: x86_64-apple-darwin
os: macos-latest
archive: tar.gz
- target: aarch64-apple-darwin
os: macos-latest
archive: tar.gz
steps:
- uses: actions/checkout@v6
with:
ref: ${{ github.event.workflow_run.head_sha || github.sha }}
- uses: oxidized-mc/ci/.github/actions/strip-patches@main
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install musl tools
if: matrix.target == 'x86_64-unknown-linux-musl'
run: sudo apt-get update && sudo apt-get install -y musl-tools
- name: Cache cargo
uses: actions/cache@v5
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-${{ matrix.target }}-dev-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-${{ matrix.target }}-dev-
- name: Build release binary
run: cargo build --release --target ${{ matrix.target }} -p ${{ inputs.package-name }}
- name: Determine version
id: version
shell: bash
run: |
BASE_VERSION=$(grep '^version' Cargo.toml | head -1 | sed 's/.*"\(.*\)".*/\1/')
SHA="${{ github.event.workflow_run.head_sha || github.sha }}"
SHORT_SHA=$(echo "${SHA}" | cut -c1-7)
TIMESTAMP=$(date -u +%Y%m%d%H%M%S)
echo "version=${BASE_VERSION}-dev.t${TIMESTAMP}.${SHORT_SHA}" >> "$GITHUB_OUTPUT"
echo "short_sha=${SHORT_SHA}" >> "$GITHUB_OUTPUT"
- name: Package (Unix)
if: matrix.archive == 'tar.gz'
shell: bash
run: |
DIST_DIR="${{ inputs.binary-name }}-nightly-${{ matrix.target }}"
mkdir -p "${DIST_DIR}"
cp "target/${{ matrix.target }}/release/${{ inputs.binary-name }}" "${DIST_DIR}/"
for f in LICENSE LICENSE-MIT LICENSE-APACHE README.md ${{ inputs.extra-files }}; do
[ -f "$f" ] && cp "$f" "${DIST_DIR}/" || true
done
tar czf "${DIST_DIR}.tar.gz" "${DIST_DIR}"
echo "ASSET=${DIST_DIR}.tar.gz" >> "$GITHUB_ENV"
- name: Package (Windows)
if: matrix.archive == 'zip'
shell: pwsh
run: |
$DIST_DIR = "${{ inputs.binary-name }}-nightly-${{ matrix.target }}"
New-Item -ItemType Directory -Path $DIST_DIR
Copy-Item "target/${{ matrix.target }}/release/${{ inputs.binary-name }}.exe" "$DIST_DIR/"
foreach ($f in @("LICENSE", "LICENSE-MIT", "LICENSE-APACHE", "README.md") + "${{ inputs.extra-files }}".Split(" ", [StringSplitOptions]::RemoveEmptyEntries)) {
if (Test-Path $f) { Copy-Item $f "$DIST_DIR/" }
}
Compress-Archive -Path "$DIST_DIR/*" -DestinationPath "$DIST_DIR.zip"
echo "ASSET=$DIST_DIR.zip" | Out-File -Append -Encoding utf8 $env:GITHUB_ENV
- name: Generate SHA256
shell: bash
run: |
if command -v sha256sum &>/dev/null; then
sha256sum "${{ env.ASSET }}" > "${{ env.ASSET }}.sha256"
else
shasum -a 256 "${{ env.ASSET }}" > "${{ env.ASSET }}.sha256"
fi
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: ${{ inputs.binary-name }}-nightly-${{ matrix.target }}
path: |
${{ env.ASSET }}
${{ env.ASSET }}.sha256
publish:
name: Publish nightly release
needs: dev-release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
ref: ${{ github.event.workflow_run.head_sha || github.sha }}
- name: Download all artifacts
uses: actions/download-artifact@v8
with:
path: dist/
merge-multiple: true
- name: Determine version
id: version
shell: bash
run: |
BASE_VERSION=$(grep '^version' Cargo.toml | head -1 | sed 's/.*"\(.*\)".*/\1/')
SHA="${{ github.event.workflow_run.head_sha || github.sha }}"
SHORT_SHA=$(echo "${SHA}" | cut -c1-7)
TIMESTAMP=$(date -u +%Y%m%d%H%M%S)
echo "version=${BASE_VERSION}-dev.t${TIMESTAMP}.${SHORT_SHA}" >> "$GITHUB_OUTPUT"
echo "short_sha=${SHORT_SHA}" >> "$GITHUB_OUTPUT"
echo "date=$(date -u +%Y-%m-%d)" >> "$GITHUB_OUTPUT"
- name: Generate combined SHA256SUMS
working-directory: dist
run: |
cat *.sha256 > SHA256SUMS
cat SHA256SUMS
- name: Create or update nightly release
uses: softprops/action-gh-release@v2
with:
tag_name: nightly
name: "Nightly (${{ steps.version.outputs.date }} — ${{ steps.version.outputs.short_sha }})"
body: |
**⚠️ Development build — not for production use.**
Built from [`${{ steps.version.outputs.short_sha }}`](${{ github.server_url }}/${{ github.repository }}/commit/${{ github.event.workflow_run.head_sha || github.sha }}) on ${{ steps.version.outputs.date }}.
Version: `${{ steps.version.outputs.version }}`
Verify checksums: `sha256sum -c SHA256SUMS`
prerelease: true
make_latest: false
files: dist/*