-
Notifications
You must be signed in to change notification settings - Fork 2
103 lines (97 loc) · 3.54 KB
/
release.yml
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
name: release
concurrency:
group: build-binary-${{ github.ref }}
cancel-in-progress: true
on:
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Create release
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create ${{ github.ref_name }} -t ${{ github.ref_name }} --generate-notes
build-binary:
needs: publish
runs-on: ${{ matrix.image }}
strategy:
matrix:
include:
- image: ubuntu-latest
target: x86_64-unknown-linux-gnu
- image: ubuntu-latest
target: x86_64-unknown-linux-musl
- image: macos-latest
target: x86_64-apple-darwin
- image: ubuntu-latest
target: x86_64-pc-windows-gnu
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Cache cargo
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Install Rust stable
run: |
rustup toolchain install stable --target ${{ matrix.target }}
- if: contains(matrix.target, 'windows')
name: Install Windows dependencies
run: |
sudo apt update
sudo apt install -y gcc-mingw-w64
- if: contains(matrix.target, 'apple')
name: Install Apple dependencies
run: |
brew install openssl coreutils
- name: Build
run: |
cargo build --release --target ${{ matrix.target }}
- name: Get package name
id: package-name
run: |
cargo install --path .
echo "metadata=$(cargo get package.name)" >> $GITHUB_OUTPUT
- name: Get binary name
id: binary-name
run: |
if [[ "${{ matrix.target }}" == *"windows"* ]]; then
echo "binary-name=${{ steps.package-name.outputs.metadata }}.exe" >> $GITHUB_OUTPUT
else
echo "binary-name=${{ steps.package-name.outputs.metadata }}" >> $GITHUB_OUTPUT
fi
- name: Rename binary
run: |
cp target/${{ matrix.target }}/release/${{ steps.binary-name.outputs.binary-name }} target/${{ matrix.target }}/release/${{ steps.package-name.outputs.metadata }}-${{ matrix.target }}
- name: Checksum
run: |
cd target/${{ matrix.target }}/release
sha256sum ${{ steps.package-name.outputs.metadata }}-${{ matrix.target }} > ${{ steps.package-name.outputs.metadata }}-${{ matrix.target }}.sha256
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ steps.package-name.outputs.metadata }}-${{ matrix.target }}
path: |
target/${{ matrix.target }}/release/${{ steps.package-name.outputs.metadata }}-${{ matrix.target }}
target/${{ matrix.target }}/release/${{ steps.package-name.outputs.metadata }}-${{ matrix.target }}.sha256
if-no-files-found: error
- if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
name: Upload assets
uses: softprops/action-gh-release@v1
with:
files: |
target/${{ matrix.target }}/release/${{ steps.package-name.outputs.metadata }}-${{ matrix.target }}
target/${{ matrix.target }}/release/${{ steps.package-name.outputs.metadata }}-${{ matrix.target }}.sha256