-
Notifications
You must be signed in to change notification settings - Fork 5
152 lines (127 loc) · 4.34 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
name: Release
on:
schedule:
- cron: "0 0 * * 1"
workflow_dispatch:
# Allow only one release workflow at a time to avoid using shared resources (tags, ...).
# See https://docs.github.com/en/actions/using-jobs/using-concurrency for details.
concurrency:
group: ${{ github.workflow }}
permissions:
contents: write
jobs:
get-next-version:
uses: semantic-release-action/next-release-version/.github/workflows/next-release-version.yml@v4
build:
name: Build for ${{ matrix.build.target }}
if: needs.get-next-version.outputs.new-release-published == 'true'
runs-on: ${{ matrix.build.os }}
needs:
- get-next-version
strategy:
matrix:
build:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
cross: false
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
id: rust-toolchain
with:
toolchain: stable
target: ${{ matrix.build.target }}
- name: Cache cargo
uses: actions/cache@v4
id: cache-cargo
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ steps.rust-toolchain.outputs.cachekey }}-${{ hashFiles('**/Cargo.lock') }}
- name: Install semantic-release-cargo
uses: taiki-e/install-action@v2
with:
tool: [email protected]
- name: Prepare semantic-release for Rust
run: semantic-release-cargo prepare ${{ needs.get-next-version.outputs.new-release-version }}
- name: Install cross
uses: taiki-e/install-action@v2
with:
tool: cross
- name: Configure cross
if: matrix.build.cross
run: echo "CARGO=cross" >> "$GITHUB_ENV"
- name: Compile release binary
run: cargo build --release --target ${{ matrix.build.target }} --verbose
- name: Create release archive
run: |
mkdir dist
cp target/${{ matrix.build.target }}/release/gitlab-ci-ls dist/gitlab-ci-ls-${{ matrix.build.target }}
- name: Create binary checksum
run: shasum --algorithm 256 --binary gitlab-ci-ls-${{ matrix.build.target }} | tee gitlab-ci-ls-${{ matrix.build.target }}-checksums.txt
working-directory: ./dist
- name: Upload release artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.build.target }}
path: |
dist/gitlab-ci-ls-${{ matrix.build.target }}
dist/gitlab-ci-ls-${{ matrix.build.target }}-checksums.txt
if-no-files-found: error
retention-days: 1
release:
runs-on: ubuntu-latest
name: Release
if: needs.get-next-version.outputs.new-release-published == 'true'
needs:
- build
- get-next-version
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
id: rust-toolchain
with:
toolchain: stable
- name: Cache cargo
uses: actions/cache@v4
id: cache-cargo
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ steps.rust-toolchain.outputs.cachekey }}-${{ hashFiles('**/Cargo.lock') }}
- name: Download release artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: ls artifacts
run: ls -R ./artifacts
- name: Prepare GitHub Release artifacts
run: |
mkdir ./dist
mv ./artifacts/x86_64-unknown-linux-gnu ./dist
- name: Combine checksums
run: cat dist/**/gitlab-ci-ls-*-checksums.txt | tee dist/checksums.txt
- name: Semantic Release
uses: cycjimmy/semantic-release-action@v4
with:
extra_plugins: |
semantic-release-cargo
@semantic-release/git
env:
GITHUB_TOKEN: ${{ secrets.PAT }}
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
DEBUG: semantic-release:*