-
Notifications
You must be signed in to change notification settings - Fork 0
180 lines (155 loc) · 5.35 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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
name: release
permissions:
contents: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
pull_request:
push:
branches:
- trunk
tags:
- "*"
workflow_dispatch:
defaults:
run:
shell: bash
env:
name: row
CARGO_TERM_COLOR: always
CLICOLOR: 1
RUST_VERSION: 1.83.0
jobs:
source:
name: Build source tarball
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
path: code
- name: Determine filename-safe ref from GITHUB_REF_NAME
run: echo ref="$(echo "${GITHUB_REF_NAME}" | sed -e 's/\//-/g')" >> "$GITHUB_ENV"
- name: Copy source
run: cp -R code "${name}-${ref}"
- name: Remove .git
run: rm -rf "${name}-${ref}/.git" && ls -laR "${name}-${ref}"
- name: Tar/zstd source
run: tar --zstd -cvf "${name}-${ref}.tar.zst" "${name}-${ref}"
- uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: source
path: |
*.tar.*
release-notes:
name: Extract release notes
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
path: code
- name: Write release-notes.md
# 1. Search for the content from the start of the file to the 2nd version heading.
# 2. Remove the 2nd version heading.
# 3. Search for the content after the first version heading (removes any description at the
# start of the file.
# 4. Remove the 1st version heading.
# This leaves the content of the release notes for the current release.
run: >
grep -P -m 2 -B 10000 "^## v*\d*\.\d*\.\d*" doc/src/release-notes.md |
sed '$d' |
grep -P -A 10000 "^## v*\d*\.\d*\.\d*" |
sed '1d' |
tee "${GITHUB_WORKSPACE}/release-notes.md"
working-directory: code
- uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: release-notes
path: |
release-notes.md
binary:
name: Build [${{ matrix.target }}]
runs-on: ${{ matrix.runner }}
strategy:
matrix:
target:
- x86_64-unknown-linux-gnu
- aarch64-apple-darwin
include:
- target: x86_64-unknown-linux-gnu
runner: ubuntu-20.04
- target: aarch64-apple-darwin
runner: macos-14
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Determine filename-safe ref from GITHUB_REF_NAME
run: echo ref="$(echo "${GITHUB_REF_NAME}" | sed -e 's/\//-/g')" >> "$GITHUB_ENV"
- name: Update rust
run: rustup install "$RUST_VERSION" --no-self-update && rustup default "$RUST_VERSION"
- name: Check rust installation
run: rustc -vV
- uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-rust-${{ env.RUST_VERSION }}-cargo-release-binary-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}
- name: Build
run: cargo build --locked --bin "${name}" --release --target ${{ matrix.target }}
- name: Check output
run: file "target/${{ matrix.target }}/release/${name}"
- name: Compress
run: cp "target/${{ matrix.target }}/release/${name}" . && tar --zstd -cvf "${name}-${ref}-${{ matrix.target }}.tar.zst" "${name}"
- uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: ${{ matrix.target }}
path: "${{ env.name }}-${{ env.ref }}-${{ matrix.target }}.tar.zst"
publish_github:
name: Publish [GitHub]
needs: [binary, source, release-notes]
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
merge-multiple: true
- name: List files
run: ls -lR
- name: Create release
uses: softprops/action-gh-release@01570a1f39cb168c169c802c3bceb9e93fb10974 # v2.1.0
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
*.zst
body_path: release-notes.md
make_latest: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish_cargo:
name: Publish [Cargo]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Update rust
run: rustup install "$RUST_VERSION" --no-self-update && rustup default "$RUST_VERSION"
- name: Check rust installation
run: rustc -vV
- uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-rust-${{ env.RUST_VERSION }}-cargo-publish-${{ hashFiles('**/Cargo.lock') }}
- name: Dry run
run: cargo publish --all-features --dry-run
- name: Publish to crates.io
if: startsWith(github.ref, 'refs/tags/')
run: cargo publish --all-features --token ${{ secrets.CRATES_IO_API_TOKEN }}