-
Notifications
You must be signed in to change notification settings - Fork 16
81 lines (71 loc) · 1.92 KB
/
master.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
# Push to master workflow.
#
# Runs when a PR has been merged to the master branch.
#
# 1. Generates a release build.
# 2. If the last commit is a version change, publish.
name: Master
on:
push:
branches:
- master
env:
# Run all cargo commands with --verbose.
CARGO_TERM_VERBOSE: true
RUST_BACKTRACE: 1
jobs:
build:
name: Build
runs-on: ${{ matrix.os }}
if: "startsWith(github.event.head_commit.message, 'chore(release):')"
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
steps:
- uses: actions/checkout@v2
# Install Rust
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
# Cache.
- name: Cargo cache registry, index and build
uses: actions/[email protected]
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-cache-${{ hashFiles('**/Cargo.lock') }}
# Make sure the code builds.
- name: Build
run: cargo build --release
# Publish if we're on a tag here.
publish:
name: Publish
runs-on: ubuntu-latest
needs: build
if: "startsWith(github.event.head_commit.message, 'chore(release):')"
steps:
- uses: actions/checkout@v2
# checkout with fetch-depth: '0' to be sure to retrieve all commits to look for the semver commit message
with:
fetch-depth: '0'
## Install Rust
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
# Publish to crates.io.
- uses: actions-rs/cargo@v1
with:
command: login
args: ${{ secrets.CRATES_IO_TOKEN }}
- uses: actions-rs/cargo@v1
with:
command: package
- uses: actions-rs/cargo@v1
with:
command: publish