Repository navigation
116 lines (112 loc) · 3.74 KB
/
Copy pathrelease.yml
File metadata and controls
116 lines (112 loc) · 3.74 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
name: Release
on:
workflow_dispatch:
push:
tags:
- "v*"
jobs:
build:
name: build (${{ matrix.target }})
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
runs-on: ubuntu-latest
- target: aarch64-unknown-linux-gnu
runs-on: ubuntu-latest
cross-linker: aarch64-linux-gnu-gcc
cross-linker-apt-package: gcc-aarch64-linux-gnu
cross-linker-cargo-var: CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER
- target: x86_64-apple-darwin
runs-on: macos-latest
- target: aarch64-apple-darwin
runs-on: macos-latest
- target: x86_64-pc-windows-msvc
runs-on: windows-latest
runs-on: ${{ matrix.runs-on }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Configure cross linker
if: matrix.cross-linker != ''
run: |
sudo apt-get update
sudo apt-get install -y ${{ matrix.cross-linker-apt-package }}
echo "${{ matrix.cross-linker-cargo-var }}=${{ matrix.cross-linker }}" >> "$GITHUB_ENV"
- run: cargo build --release --target ${{ matrix.target }}
- name: Package archive
shell: bash
run: |
set -euo pipefail
version=$(grep -m1 -E '^version = "' Cargo.toml | sed -E 's/version = "([^"]+)"/\1/')
stem="nbx-${version}-${{ matrix.target }}"
mkdir -p "${stem}"
if [ "${{ runner.os }}" = "Windows" ]; then
cp "target/${{ matrix.target }}/release/nbx.exe" "${stem}/"
else
cp "target/${{ matrix.target }}/release/nbx" "${stem}/"
fi
cp README.md LICENSE "${stem}/"
if [ "${{ runner.os }}" = "Windows" ]; then
7z a -tzip "${stem}.zip" "${stem}/" >/dev/null
else
tar -czf "${stem}.tar.gz" "${stem}"
fi
- uses: actions/upload-artifact@v4
with:
name: nbx-${{ matrix.target }}
path: |
nbx-*-${{ matrix.target }}.tar.gz
nbx-*-${{ matrix.target }}.zip
if-no-files-found: error
release:
runs-on: ubuntu-latest
needs: build
if: startsWith(github.ref, 'refs/tags/v')
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Verify tag matches Cargo.toml version
run: |
set -euo pipefail
version=$(grep -m1 -E '^version = "' Cargo.toml | sed -E 's/version = "([^"]+)"/\1/')
test "${GITHUB_REF_NAME}" = "v${version}"
- uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: Generate SHA256SUMS
shell: bash
run: |
set -euo pipefail
shopt -s nullglob
cd dist
files=(*.tar.gz *.zip)
sha256sum "${files[@]}" > SHA256SUMS
- uses: softprops/action-gh-release@v2
with:
files: |
dist/*.tar.gz
dist/*.zip
dist/SHA256SUMS
generate_release_notes: true
fail_on_unmatched_files: true
publish-crate:
runs-on: ubuntu-latest
needs: release
if: startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Verify tag matches Cargo.toml version
run: |
set -euo pipefail
version=$(grep -m1 -E '^version = "' Cargo.toml | sed -E 's/version = "([^"]+)"/\1/')
test "${GITHUB_REF_NAME}" = "v${version}"
- run: cargo publish -p nbx --locked
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}