Skip to content

Commit a2c2ab7

Browse files
authored
chore(dev): prepare to release individual packages (#302)
This allows us to release each package in this workspace (monorepo) individually. ## Tags The tags will now be prefixed with the package name as it appears in the respective Cargo.toml: - cpp-linter/v2.0.0-rc.1 - cpp-linter-js/v2.0.0-rc.1 - cpp-linter-js/v2.0.0-rc.1 - clang-installer/v0.1.1 > [!IMPORTANT] > Publishing a release will still happen from the bump-n-release CI workflow's manual trigger (`workflow_dispatch`). > There's an added input to select which package to publish. ## Change Logs Each package will now have its own CHANGELOG.md file (alongside the Cargo.toml) `git-cliff` is now configured to only put relevant changes in each CHANGELOG.md. The relevant changes are determined by changed file's path. ## Binary builds I updated the binary-builds CI workflow to build both rust binary executables. Upon release, the binary executables matching the released package will be uploaded as release assets (for all supported build targets).
1 parent 35ed52e commit a2c2ab7

42 files changed

Lines changed: 560 additions & 270 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/common.nu

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
2+
# A helper function to display the command being executed.
3+
#
4+
# This also prints the elapsed time the command took to execute.
5+
export def --wrapped run-cmd [...cmd: string] {
6+
let app = if (
7+
($cmd | first) == "cargo"
8+
or ($cmd | first) == "yarn"
9+
or ($cmd | first) == 'git'
10+
or ($cmd | first) == 'gh'
11+
) {
12+
($cmd | first 2) | str join ' '
13+
} else if (($cmd | first) == "uv") {
14+
mut sub_cmd = $cmd.1
15+
if ($sub_cmd == "run") {
16+
mut index = 2
17+
mut skip_val = false
18+
for arg in ($cmd | skip 2) {
19+
if ($arg | str starts-with "-") {
20+
$skip_val = true
21+
} else if $skip_val {
22+
$skip_val = false
23+
} else {
24+
break
25+
}
26+
$index = $index + 1
27+
}
28+
if (($cmd | get $index) == "cargo") {
29+
$sub_cmd = $cmd | skip $index | first 2 | str join ' '
30+
}
31+
$sub_cmd
32+
} else {
33+
($cmd | first 2) | str join ' '
34+
}
35+
} else {
36+
($cmd | first)
37+
}
38+
print $"(ansi blue)\nRunning(ansi reset) ($cmd | str join ' ')"
39+
let elapsed = timeit {|| ^($cmd | first) ...($cmd | skip 1)}
40+
print $"(ansi magenta)($app) took ($elapsed)(ansi reset)"
41+
}

.github/workflows/binary-builds.yml

Lines changed: 45 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,20 @@ on:
66
paths:
77
- cpp-linter/src/**
88
- cpp-linter/Cargo.toml
9+
- clang-installer/src/**
10+
- clang-installer/Cargo.toml
911
- Cargo.toml
1012
- Cargo.lock
1113
tags:
12-
- v*
14+
- cpp-linter/v*
15+
- clang-installer/v*
1316
pull_request:
1417
branches: [main]
1518
paths:
1619
- cpp-linter/src/**
1720
- cpp-linter/Cargo.toml
21+
- clang-installer/src/**
22+
- clang-installer/Cargo.toml
1823
- Cargo.toml
1924
- Cargo.lock
2025

@@ -127,8 +132,8 @@ jobs:
127132
run: >-
128133
${{ matrix.cross && 'cross' || 'cargo '}}
129134
build
130-
--manifest-path cpp-linter/Cargo.toml
131135
--bin cpp-linter
136+
--bin clang-tools
132137
--release
133138
--target ${{ matrix.target }}
134139
--features ${{ matrix.vendored && 'bin,openssl-vendored' || 'bin' }}
@@ -137,30 +142,53 @@ jobs:
137142
if: runner.os != 'Windows'
138143
shell: bash
139144
run: |-
145+
mkdir dist
146+
cp LICENSE dist/LICENSE
147+
cd dist
148+
140149
tgt="cpp-linter"
141-
mv "target/${{ matrix.target }}/release/${tgt}" "${tgt}"
142-
arc_name="cpp-linter-${{ matrix.target }}.tar.gz"
150+
mv "../target/${{ matrix.target }}/release/${tgt}" "./${tgt}"
151+
arc_name="${tgt}-${{ matrix.target }}.tar.gz"
152+
tar -a -c -v -z -f "${arc_name}" ${tgt} LICENSE
153+
154+
tgt="clang-tools"
155+
mv "../target/${{ matrix.target }}/release/${tgt}" "./${tgt}"
156+
arc_name="${tgt}-${{ matrix.target }}.tar.gz"
143157
tar -a -c -v -z -f "${arc_name}" ${tgt} LICENSE
144158
- name: Prepare artifacts (windows)
145159
if: runner.os == 'Windows'
146160
shell: pwsh
147161
# `tar.exe` in powershell is different from `tar` in bash.
148162
# need to use `tar.exe` in powershell to create a valid zip file.
149163
run: |-
150-
$tgt = "cpp-linter.exe"
151-
mv "target/${{ matrix.target }}/release/${tgt}" "${tgt}"
152-
$arc_name = "cpp-linter-${{ matrix.target }}.zip"
153-
tar -a -c -v -f "${arc_name}" ${tgt} LICENSE
164+
mkdir dist
165+
Copy-Item ./LICENSE ./dist/LICENSE
166+
cd dist
167+
168+
$tgt = "cpp-linter"
169+
mv "../target/${{ matrix.target }}/release/${tgt}.exe" "./${tgt}.exe"
170+
$arc_name = "${tgt}-${{ matrix.target }}.zip"
171+
tar -a -c -v -f "${arc_name}" ${tgt}.exe LICENSE
154172
155-
- name: Upload artifacts
173+
$tgt = "clang-tools"
174+
mv "../target/${{ matrix.target }}/release/${tgt}.exe" "./${tgt}.exe"
175+
$arc_name = "${tgt}-${{ matrix.target }}.zip"
176+
tar -a -c -v -f "${arc_name}" ${tgt}.exe LICENSE
177+
- name: Upload cpp-linter artifacts
156178
uses: actions/upload-artifact@v7
157179
with:
158180
name: cpp-linter-${{ matrix.target }}
159-
path: cpp-linter-${{ matrix.target }}*
181+
path: dist/cpp-linter-${{ matrix.target }}*
182+
if-no-files-found: error
183+
- name: Upload clang-tools artifacts
184+
uses: actions/upload-artifact@v7
185+
with:
186+
name: clang-tools-${{ matrix.target }}
187+
path: dist/clang-tools-${{ matrix.target }}*
160188
if-no-files-found: error
161189

162190
publish:
163-
if: startswith(github.ref, 'refs/tags')
191+
if: startswith(github.ref, 'refs/tags/cpp-linter/v') || startswith(github.ref, 'refs/tags/clang-installer/v')
164192
runs-on: ubuntu-latest
165193
needs: [create-assets]
166194
permissions:
@@ -172,26 +200,25 @@ jobs:
172200
persist-credentials: false
173201
- name: Install Rust
174202
run: rustup update stable --no-self-update
175-
- uses: actions/setup-python@v6
176-
with:
177-
python-version: 3.x
178203
- name: Download built assets
179204
uses: actions/download-artifact@v8
180205
with:
181-
pattern: cpp-linter-*
206+
pattern: ${{ startsWith(github.ref_name, 'cpp-linter') && 'cpp-linter' || 'clang-tools' }}-*
182207
path: dist
183208
merge-multiple: true
184209
- name: Create a Github Release
185210
env:
211+
BIN_NAME: ${{ startsWith(github.ref_name, 'cpp-linter') && 'cpp-linter' || 'clang-tools' }}
186212
GH_TOKEN: ${{ github.token }}
187213
GIT_REF: ${{ github.ref_name }}
188214
run: |
189-
files=$(ls dist/cpp-linter*)
190-
gh release upload "$GIT_REF" $files
215+
files=$(ls dist/${BIN_NAME}*)
216+
gh release upload "${GIT_REF}" ${files}
191217
- name: Establish provenance
192218
id: auth
193219
uses: rust-lang/crates-io-auth-action@bbd81622f20ce9e2dd9622e3218b975523e45bbe # v1.0.4
194220
- name: Publish package
195221
env:
222+
PKG_NAME: ${{ startsWith(github.ref_name, 'cpp-linter') && 'cpp-linter' || 'clang-installer' }}
196223
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
197-
run: cargo publish -p cpp-linter
224+
run: cargo publish -p ${PKG_NAME}

0 commit comments

Comments
 (0)