-
Notifications
You must be signed in to change notification settings - Fork 0
131 lines (124 loc) · 3.73 KB
/
pipeline.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
name: Pipeline
on:
push:
branches:
- '*'
pull_request:
permissions:
contents: write
jobs:
run-tests:
uses: ./.github/workflows/run-tests.yml
bump-cargo-version:
runs-on: ubuntu-latest
needs:
- run-tests
if: github.ref == 'refs/heads/main' && needs.run-tests.outputs.will-bump == 'true'
steps:
- uses: actions/checkout@v4
name: Checkout the repository
- uses: actions/cache@v3.3.2
name: Cache cargo dependencies
with:
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
path: |
.cache
~/.cargo/registry
~/.cargo/git
~/.cargo/bin
target
- uses: actions-rs/toolchain@v1.0.7
name: Install rust toolchain
with:
default: true
profile: minimal
toolchain: stable
- uses: actions-rs/cargo@v1.0.3
name: Build release version
with:
args: --release --locked
command: build
- name: Install cargo-edit
run: cargo install cargo-edit
- name: Set Cargo version
run: cargo set-version "${NEW_VERSION#v}"
env:
NEW_VERSION: ${{ needs.run-tests.outputs.bump-version }}
- name: Store updated Cargo files
uses: actions/upload-artifact@v3
with:
name: bumped-files
path: Cargo.*
build-binaries:
if: github.ref == 'refs/heads/main'
runs-on: ${{ matrix.os }}
needs:
- run-tests
steps:
- run: ${{ matrix.install }}
env:
DEBIAN_FRONTEND: noninteractive
name: Install additional dependencies
- uses: actions/checkout@v4
name: Checkout the repository
- uses: actions/cache@v3.3.2
name: Cache cargo dependencies
with:
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
path: |
.cache
~/.cargo/registry
~/.cargo/git
~/.cargo/bin
target
- uses: actions-rs/toolchain@v1.0.7
name: Install rust toolchain
with:
default: true
profile: minimal
toolchain: stable
- uses: actions-rs/cargo@v1.0.3
name: Build release version
with:
args: --release --locked
command: build
- id: get_repository_name
name: Calculate repository name
run: echo "REPOSITORY_NAME=$(echo "$GITHUB_REPOSITORY" | awk
-F / '{print $2}' | sed -e "s/:refs//")" >> "$GITHUB_OUTPUT"
shell: bash
- name: Move binary to upload location
env:
TARGET: ${{ matrix.target }}
EXTENSION: ${{ matrix.suffix }}
REPOSITORY_NAME: ${{ steps.get_repository_name.outputs.REPOSITORY_NAME }}
run: mv "./target/release/$REPOSITORY_NAME$EXTENSION" "./$REPOSITORY_NAME-$TARGET$EXTENSION"
shell: bash
- uses: actions/upload-artifact@v3
name: Store built binary version
with:
name: bins
path: ${{ steps.get_repository_name.outputs.REPOSITORY_NAME }}-${{ matrix.target }}${{ matrix.suffix }}
strategy:
matrix:
include:
- os: macos-latest
suffix: ''
target: x86_64-apple-darwin
install: ''
- os: ubuntu-latest
suffix: ''
target: x86_64-unknown-linux-gnu
install: ''
- os: windows-latest
suffix: .exe
target: x86_64-pc-windows-msvc
install: ''
tag-and-release:
needs:
- build-binaries
- bump-cargo-version
uses: armakuni/github-actions/.github/workflows/tag-and-release.yml@v0.18.1
with:
download-artifacts: true
release-artifacts: ./bins/*