-
Notifications
You must be signed in to change notification settings - Fork 2
104 lines (97 loc) · 3.04 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
104
name: release
on:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+'
env:
CARGO_TERM_COLOR: always
jobs:
verify-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: |
tag="${GITHUB_REF#refs/tags/}"
package_version="$(cargo read-manifest | jq --raw-output .version)"
echo "Git tag name: ${tag}"
echo "Cargo.toml version: ${package_version}"
test "$tag" == "$package_version"
# Run the tests and create a fresh cache before releasing. Make sure that the
# same code that was tested is what gets released.
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target/release
key: release-${{ runner.os }}-${{ github.job }}-${{ secrets.CI_CACHE_VERSION }}
- run: cargo test --release
publish-binary:
needs:
- verify-version
- test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
include:
- os: macos-latest
artifact_prefix: macos-x86-64
target: x86_64-apple-darwin
- os: ubuntu-latest
artifact_prefix: linux-x86-64
target: x86_64-unknown-linux-gnu
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target/release
key: release-${{ runner.os }}-${{ github.job }}-${{ secrets.CI_CACHE_VERSION }}
- run: cargo build --release --target ${{ matrix.target }}
- name: package binary
shell: bash
run: |
cd target/${{ matrix.target }}/release
strip ${{ github.event.repository.name }}
tar czvf \
${{ github.event.repository.name }}-${{ matrix.artifact_prefix }}.tar.gz \
${{ github.event.repository.name }}
shasum -a 256 ${{ github.event.repository.name }}-${{ matrix.artifact_prefix }}.tar.gz \
> ${{ github.event.repository.name }}-${{ matrix.artifact_prefix }}.sha256
- name: publish release to github
uses: softprops/action-gh-release@v1
with:
files: |
target/${{ matrix.target }}/release/${{ github.event.repository.name }}-${{ matrix.artifact_prefix }}.tar.gz
target/${{ matrix.target }}/release/${{ github.event.repository.name }}-${{ matrix.artifact_prefix }}.sha256
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish-crate:
needs:
- verify-version
- test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target/release
key: release-${{ runner.os }}-${{ github.job }}-${{ secrets.CI_CACHE_VERSION }}
- run: cargo publish --token ${{ secrets.CARGO_API_TOKEN }} --allow-dirty