-
Notifications
You must be signed in to change notification settings - Fork 9
72 lines (60 loc) · 1.98 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
name: Release
on:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+'
- '[0-9]+.[0-9]+.[0-9]+-**'
branches:
- 'release-test-[0-9]+.[0-9]+.[0-9]+'
jobs:
# This job is responsible for creating the release _once_ for each tag.
create-release:
name: Create release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Get release version
run: |
echo "Ref: $GITHUB_REF"
ref_no_tag=${GITHUB_REF#refs/tags/}
echo "No tag: $ref_no_tag"
protofish_version=${ref_no_tag#refs/heads/release-test-}
echo "Final: $protofish_version"
echo "PROTOFISH_VERSION=${protofish_version}" >> $GITHUB_ENV
echo "Version: ${{ env.PROTOFISH_VERSION }}"
if [[ $GITHUB_REF == *"release-test"* ]]; then
echo "Release test"
echo "REAL_RELEASE=false" >> $GITHUB_ENV
else
echo "Normal release"
echo "REAL_RELEASE=true" >> $GITHUB_ENV
fi
- name: Version check
run: |
toml_version="$(head Cargo.toml | grep "^version" | sed 's/.*"\(.*\)".*/\1/')"
if [ "$toml_version" != "${{ env.PROTOFISH_VERSION }}" ]; then
echo "Version mismatch!"
echo "Tag: ${{ env.PROTOFISH_VERSION }}"
echo "Crate: $toml_version"
exit 1
else
echo "TOML and Git versions match"
fi
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
- name: Environment
run: |
cargo --version
rustc --version
- name: Test release
run: |
cargo test --release
- name: Publish to crates.io
if: env.REAL_RELEASE == 'true'
run: |
cargo publish --token "${{ secrets.crates_io }}"