-
Notifications
You must be signed in to change notification settings - Fork 1
183 lines (161 loc) · 5.11 KB
/
release-cargo-mono.yml
File metadata and controls
183 lines (161 loc) · 5.11 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
name: Release cargo-mono
on:
push:
tags:
- "cargo-mono@v*"
workflow_dispatch:
inputs:
version:
description: "Semver without v prefix (for example: 0.2.0)"
required: true
dry_run:
description: "If true, skip GitHub release publication"
required: false
default: "true"
type: choice
options:
- "true"
- "false"
permissions:
contents: write
id-token: write
concurrency:
group: release-cargo-mono-${{ github.ref }}
cancel-in-progress: false
jobs:
prepare:
name: Prepare metadata
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.meta.outputs.tag }}
version: ${{ steps.meta.outputs.version }}
dry_run: ${{ steps.meta.outputs.dry_run }}
steps:
- name: Resolve release metadata
id: meta
shell: bash
run: |
set -euo pipefail
if [ "${GITHUB_EVENT_NAME}" = "workflow_dispatch" ]; then
tag="cargo-mono@v${{ github.event.inputs.version }}"
dry_run="${{ github.event.inputs.dry_run }}"
else
tag="${GITHUB_REF_NAME}"
dry_run="false"
fi
version="${tag#cargo-mono@v}"
echo "tag=$tag" >> "$GITHUB_OUTPUT"
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "dry_run=$dry_run" >> "$GITHUB_OUTPUT"
build:
name: Build (${{ matrix.asset_os }}-${{ matrix.asset_arch }})
runs-on: ${{ matrix.os }}
needs: prepare
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
asset_os: linux
asset_arch: amd64
archive_ext: tar.gz
- os: ubuntu-24.04-arm
target: aarch64-unknown-linux-gnu
asset_os: linux
asset_arch: arm64
archive_ext: tar.gz
- os: macos-15-intel
target: x86_64-apple-darwin
asset_os: darwin
asset_arch: amd64
archive_ext: tar.gz
- os: macos-14
target: aarch64-apple-darwin
asset_os: darwin
asset_arch: arm64
archive_ext: tar.gz
- os: windows-latest
target: x86_64-pc-windows-msvc
asset_os: windows
asset_arch: amd64
archive_ext: zip
- os: windows-11-arm
target: aarch64-pc-windows-msvc
asset_os: windows
asset_arch: arm64
archive_ext: zip
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@v1
with:
toolchain: nightly-2026-01-01
target: ${{ matrix.target }}
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2
- name: Build cargo-mono
shell: bash
run: |
set -euo pipefail
cargo build -p cargo-mono --release --target "${{ matrix.target }}"
- name: Package artifact
shell: bash
run: |
set -euo pipefail
mkdir -p dist
artifact_name="cargo-mono-${{ matrix.asset_os }}-${{ matrix.asset_arch }}.${{ matrix.archive_ext }}"
if [ "${{ matrix.asset_os }}" = "windows" ]; then
cp "target/${{ matrix.target }}/release/cargo-mono.exe" dist/cargo-mono.exe
pwsh -NoLogo -NoProfile -Command "Compress-Archive -Path dist/cargo-mono.exe -DestinationPath dist/${artifact_name}"
rm -f dist/cargo-mono.exe
else
cp "target/${{ matrix.target }}/release/cargo-mono" dist/cargo-mono
tar -C dist -czf "dist/${artifact_name}" cargo-mono
fi
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: cargo-mono-${{ matrix.asset_os }}-${{ matrix.asset_arch }}
path: dist/*
publish:
name: Publish release
runs-on: ubuntu-latest
needs:
- prepare
- build
env:
RELEASE_TAG: ${{ needs.prepare.outputs.tag }}
DRY_RUN: ${{ needs.prepare.outputs.dry_run }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Download artifacts
uses: actions/download-artifact@v8
with:
path: dist
- name: Flatten artifact directory
shell: bash
run: |
set -euo pipefail
mkdir -p release-dist
find dist -maxdepth 2 -type f -exec cp "{}" "release-dist/" \;
rm -rf dist
mv release-dist dist
find dist -maxdepth 1 -type f | sed 's#^#artifact: #' >&2
- name: Install cosign
uses: sigstore/cosign-installer@v4.1.1
- name: Generate checksums and signatures
shell: bash
run: |
set -euo pipefail
chmod +x ./scripts/release/generate-checksums.sh
./scripts/release/generate-checksums.sh --artifacts-dir dist
- name: Create GitHub release
if: env.DRY_RUN != 'true'
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.RELEASE_TAG }}
files: dist/*
generate_release_notes: true