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
name: release
on:
push:
tags:
- "v*.*.*"
workflow_dispatch:
# Read-only by default; jobs opt into more.
permissions: read-all
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
jobs:
build:
name: build (${{ matrix.target }})
runs-on: ${{ matrix.os }}
permissions:
contents: read
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
archive: tar.gz
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
archive: tar.gz
cross: true
- os: macos-latest
target: x86_64-apple-darwin
archive: tar.gz
- os: macos-latest
target: aarch64-apple-darwin
archive: tar.gz
- os: windows-latest
target: x86_64-pc-windows-msvc
archive: zip
steps:
- name: Checkout
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
with:
persist-credentials: false
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Cache cargo
uses: Swatinem/rust-cache@23869a5bd66c73db3c0ac40331f3206eb23791dc # v2.9.1
with:
key: ${{ matrix.target }}
- name: Install cross (linux-aarch64 only)
if: matrix.cross
run: cargo install cross --locked
- name: Build
shell: bash
run: |
if [[ "${{ matrix.cross }}" == "true" ]]; then
cross build --release --target ${{ matrix.target }}
else
cargo build --release --target ${{ matrix.target }}
fi
- name: Package
shell: bash
run: |
set -euo pipefail
name="aiscope-${GITHUB_REF_NAME}-${{ matrix.target }}"
mkdir "$name"
if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
cp "target/${{ matrix.target }}/release/aiscope.exe" "$name/"
else
cp "target/${{ matrix.target }}/release/aiscope" "$name/"
fi
cp README.md LICENSE CHANGELOG.md "$name/"
if [[ "${{ matrix.archive }}" == "zip" ]]; then
7z a "$name.zip" "$name"
echo "ASSET=$name.zip" >> "$GITHUB_ENV"
else
tar czf "$name.tar.gz" "$name"
echo "ASSET=$name.tar.gz" >> "$GITHUB_ENV"
fi
- name: Checksum
shell: bash
run: |
if [[ "${{ matrix.os }}" == "macos-latest" ]]; then
shasum -a 256 "$ASSET" > "$ASSET.sha256"
else
sha256sum "$ASSET" > "$ASSET.sha256"
fi
- name: Upload artifact
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: ${{ matrix.target }}
path: |
${{ env.ASSET }}
${{ env.ASSET }}.sha256
publish:
name: publish github release
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
with:
persist-credentials: false
- name: Download artifacts
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
path: dist
- name: Extract release notes from CHANGELOG
shell: bash
run: |
set -euo pipefail
version="${GITHUB_REF_NAME#v}"
# Print everything between "## [<version>]" and the next "## [" heading.
awk -v ver="$version" '
$0 ~ "^## \\[" ver "\\]" { found=1; next }
found && /^## \[/ { exit }
found { print }
' CHANGELOG.md > RELEASE_NOTES.md
if [ ! -s RELEASE_NOTES.md ]; then
echo "Release ${GITHUB_REF_NAME}" > RELEASE_NOTES.md
fi
echo "----- RELEASE_NOTES.md -----"
cat RELEASE_NOTES.md
- name: Create GitHub Release
uses: softprops/action-gh-release@3bb12739c298aeb8a4eeaf626c5b8d85266b0e65 # v2.6.2
with:
generate_release_notes: true
body_path: RELEASE_NOTES.md
files: dist/*/*
crates-io:
name: publish crates.io
needs: publish
runs-on: ubuntu-latest
if: ${{ vars.PUBLISH_CRATES_IO == 'true' }}
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
with:
persist-credentials: false
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: cargo publish --locked