-
-
Notifications
You must be signed in to change notification settings - Fork 0
120 lines (104 loc) · 3.36 KB
/
build_and_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
name: Build and Release
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
release:
permissions:
contents: write
pages: write
id-token: write
packages: write
attestations: write
env:
CARGO_TERM_COLOR: always
jobs:
build:
name: Build ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
artifact_name: french-names-extractor
asset_name: insee-names-extractor-linux-amd64
- os: windows-latest
target: x86_64-pc-windows-msvc
artifact_name: french-names-extractor.exe
asset_name: insee-names-extractor-windows-amd64.exe
- os: macos-latest
target: x86_64-apple-darwin
artifact_name: french-names-extractor
asset_name: insee-names-extractor-macos-x86_64
- os: macos-latest
target: aarch64-apple-darwin
artifact_name: french-names-extractor
asset_name: insee-names-extractor-macos-arm64
steps:
- uses: actions/checkout@v4
# on ubuntu install musl-dev and musl-tools
- name: Install musl
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y musl-dev musl-tools
- name: Install Rust
uses: crusty-pie/toolchain@main
with:
targets: ${{ matrix.target }}
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: ~/.cargo/registry
key: ${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo index
uses: actions/cache@v4
with:
path: ~/.cargo/git
key: ${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo build
uses: actions/cache@v4
with:
path: target
key: ${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}
- name: Build
continue-on-error: true
run: cargo build --verbose --release --target ${{ matrix.target }}
- name: Rename binary
continue-on-error: true
shell: bash
run: |
if [ "${{ matrix.os }}" = "windows-latest" ]; then
cp target/${{ matrix.target }}/release/${{ matrix.artifact_name }} ${{ matrix.asset_name }}
else
cp target/${{ matrix.target }}/release/${{ matrix.artifact_name }} ${{ matrix.asset_name }}
fi
- name: Upload binary
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.asset_name }}
path: ${{ matrix.asset_name }}
retention-days: 90
- name: Attest release
uses: actions/attest-build-provenance@v1
with:
subject-path: '${{ matrix.asset_name }}'
release:
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: |
insee-names-extractor-linux-amd64
insee-names-extractor-windows-amd64.exe
insee-names-extractor-macos-x86_64
insee-names-extractor-macos-arm64
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}