-
Notifications
You must be signed in to change notification settings - Fork 10
135 lines (111 loc) · 4.12 KB
/
release.yaml
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
130
131
132
133
134
135
name: Release
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
PACKAGE_NAME: tq
on:
workflow_dispatch:
jobs:
audit:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install cargo-binstall
run: curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
- name: Install cargo-audit
run: cargo binstall cargo-audit -y
- name: Run the security audit check
run: cargo audit
get-version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get-version.outputs.version }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install cargo-binstall
run: curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
- name: Install tq
run: cargo binstall -y [email protected]
- id: get-version
name: Output the current version of the project
run: echo "version=$(tq -f Cargo.toml 'package.version')" >> "$GITHUB_OUTPUT"
build-binary:
strategy:
fail-fast: true
matrix:
architecture:
- target: "x86_64-unknown-linux-musl"
name: "amd64"
- target: "aarch64-unknown-linux-musl"
name: "arm64"
- target: "armv7-unknown-linux-musleabi"
name: "armv7"
- target: "armv7-unknown-linux-musleabihf"
name: "armv7hf"
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install cargo-binstall
run: curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
- name: Install cross
run: cargo binstall -y cross
- name: Run the tests
run: cross test --target ${{ matrix.architecture.target }} --release
- name: Build the binary for the target
run: cross build --target ${{ matrix.architecture.target }} --release --bins --all-features
- name: Create output directory
run: mkdir ./output
- name: Rename binary to use correct extension and move to output directory
run: |
mv target/${{ matrix.architecture.target }}/release/${{ env.PACKAGE_NAME }} \
./output/${{ env.PACKAGE_NAME }}
tar czvf ./output/tomlq.${{ matrix.architecture.name }}.tgz -C ./output tq
rm ./output/tq
- name: Upload the binary as an artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.PACKAGE_NAME }}-drop-${{ matrix.architecture.name }}
path: |
./output/*
release-binary:
needs:
- get-version
- build-binary
- audit
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
- name: Pull artifacts from artifact store
uses: actions/download-artifact@v4
with:
pattern: ${{ env.PACKAGE_NAME }}-drop-*
path: ./release
merge-multiple: true
- name: Install cargo-binstall
run: curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
- name: Publish a draft release to GitHub
run: |
gh release create --repo ${{ github.repository }} --draft \
-n "Latest version of ${{ env.PACKAGE_NAME }}" \
-t "${{ env.PACKAGE_NAME }} v${{ env.VERSION }}" \
${{ env.VERSION }} ./release/*
env:
GH_TOKEN: ${{ github.token }}
VERSION: ${{ needs.get-version.outputs.version }}
release-cargo:
needs:
- release-binary
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Publish ${{ env.PACKAGE_NAME }} to crates.io
run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}