-
Notifications
You must be signed in to change notification settings - Fork 1
82 lines (77 loc) · 2.53 KB
/
Copy pathrelease.yml
File metadata and controls
82 lines (77 loc) · 2.53 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
name: Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
permissions:
contents: write
jobs:
build:
name: Build ${{ matrix.asset_os }}-${{ matrix.asset_arch }}
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- runner: ubuntu-latest
target: x86_64-unknown-linux-gnu
asset_os: linux
asset_arch: x86_64
- runner: macos-15-intel
target: x86_64-apple-darwin
asset_os: darwin
asset_arch: x86_64
- runner: macos-14
target: aarch64-apple-darwin
asset_os: darwin
asset_arch: aarch64
steps:
- uses: actions/checkout@v6
- name: Install Rust target
run: |
rustup toolchain install stable --profile minimal --target "${{ matrix.target }}"
rustup default stable
- name: Build
run: cargo build --release --locked --target "${{ matrix.target }}"
env:
GNIT_COMMIT: ${{ github.sha }}
- name: Package
shell: bash
run: |
version="${GITHUB_REF_NAME#v}"
archive="gnit-${version}-${{ matrix.asset_os }}-${{ matrix.asset_arch }}.tar.gz"
mkdir -p dist package
cp "target/${{ matrix.target }}/release/gnit" package/gnit
tar -C package -czf "dist/${archive}" gnit
- uses: actions/upload-artifact@v7
with:
name: gnit-${{ matrix.asset_os }}-${{ matrix.asset_arch }}
path: dist/*.tar.gz
release:
name: Publish GitHub Release
runs-on: ubuntu-latest
needs: build
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/download-artifact@v8
with:
path: dist
merge-multiple: true
- name: Create checksums
working-directory: dist
run: shasum -a 256 *.tar.gz > checksums.txt
- name: Publish release
env:
GH_TOKEN: ${{ github.token }}
# The release job has no checkout, so gh cannot infer the repo from a
# local .git. Pin it explicitly to avoid "fatal: not a git repository".
GH_REPO: ${{ github.repository }}
run: |
if gh release view "$GITHUB_REF_NAME" >/dev/null 2>&1; then
gh release upload "$GITHUB_REF_NAME" dist/*.tar.gz dist/checksums.txt --clobber
else
gh release create "$GITHUB_REF_NAME" dist/*.tar.gz dist/checksums.txt \
--title "$GITHUB_REF_NAME" \
--notes "Gnit $GITHUB_REF_NAME"
fi