Skip to content

Commit d8a6c74

Browse files
committed
chore(dev): prepare to release individual packages
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 d8a6c74

41 files changed

Lines changed: 546 additions & 266 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: 34 additions & 15 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' }}
@@ -139,28 +144,43 @@ jobs:
139144
run: |-
140145
tgt="cpp-linter"
141146
mv "target/${{ matrix.target }}/release/${tgt}" "${tgt}"
142-
arc_name="cpp-linter-${{ matrix.target }}.tar.gz"
147+
arc_name="${tgt}-${{ matrix.target }}.tar.gz"
148+
tar -a -c -v -z -f "${arc_name}" ${tgt} LICENSE
149+
150+
tgt="clang-tools"
151+
mv "target/${{ matrix.target }}/release/${tgt}" "${tgt}"
152+
arc_name="${tgt}-${{ matrix.target }}.tar.gz"
143153
tar -a -c -v -z -f "${arc_name}" ${tgt} LICENSE
144154
- name: Prepare artifacts (windows)
145155
if: runner.os == 'Windows'
146156
shell: pwsh
147157
# `tar.exe` in powershell is different from `tar` in bash.
148158
# need to use `tar.exe` in powershell to create a valid zip file.
149159
run: |-
150-
$tgt = "cpp-linter.exe"
151-
mv "target/${{ matrix.target }}/release/${tgt}" "${tgt}"
152-
$arc_name = "cpp-linter-${{ matrix.target }}.zip"
160+
$tgt = "cpp-linter"
161+
mv "target/${{ matrix.target }}/release/${tgt}.exe" "${tgt}.exe"
162+
$arc_name = "${tgt}-${{ matrix.target }}.zip"
153163
tar -a -c -v -f "${arc_name}" ${tgt} LICENSE
154164
155-
- name: Upload artifacts
165+
$tgt = "clang-tools"
166+
mv "target/${{ matrix.target }}/release/${tgt}.exe" "${tgt}.exe"
167+
$arc_name = "${tgt}-${{ matrix.target }}.zip"
168+
tar -a -c -v -f "${arc_name}" ${tgt} LICENSE
169+
- name: Upload cpp-linter artifacts
156170
uses: actions/upload-artifact@v7
157171
with:
158172
name: cpp-linter-${{ matrix.target }}
159173
path: cpp-linter-${{ matrix.target }}*
160174
if-no-files-found: error
175+
- name: Upload clang-tools artifacts
176+
uses: actions/upload-artifact@v7
177+
with:
178+
name: clang-tools-${{ matrix.target }}
179+
path: clang-tools-${{ matrix.target }}*
180+
if-no-files-found: error
161181

162182
publish:
163-
if: startswith(github.ref, 'refs/tags')
183+
if: startswith(github.ref, 'refs/tags/cpp-linter/v') || startswith(github.ref, 'refs/tags/clang-installer/v')
164184
runs-on: ubuntu-latest
165185
needs: [create-assets]
166186
permissions:
@@ -172,26 +192,25 @@ jobs:
172192
persist-credentials: false
173193
- name: Install Rust
174194
run: rustup update stable --no-self-update
175-
- uses: actions/setup-python@v6
176-
with:
177-
python-version: 3.x
178195
- name: Download built assets
179196
uses: actions/download-artifact@v8
180197
with:
181-
pattern: cpp-linter-*
198+
pattern: ${{ startsWith(github.ref_name, 'cpp-linter') && 'cpp-linter' || 'clang-tools' }}-*
182199
path: dist
183200
merge-multiple: true
184201
- name: Create a Github Release
185202
env:
203+
BIN_NAME: ${{ startsWith(github.ref_name, 'cpp-linter') && 'cpp-linter' || 'clang-tools' }}
186204
GH_TOKEN: ${{ github.token }}
187205
GIT_REF: ${{ github.ref_name }}
188206
run: |
189-
files=$(ls dist/cpp-linter*)
190-
gh release upload "$GIT_REF" $files
207+
files=$(ls dist/${BIN_NAME}*)
208+
gh release upload "${GIT_REF}" ${files}
191209
- name: Establish provenance
192210
id: auth
193211
uses: rust-lang/crates-io-auth-action@bbd81622f20ce9e2dd9622e3218b975523e45bbe # v1.0.4
194212
- name: Publish package
195213
env:
214+
PKG_NAME: ${{ startsWith(github.ref_name, 'cpp-linter') && 'cpp-linter' || 'clang-installer' }}
196215
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
197-
run: cargo publish -p cpp-linter
216+
run: cargo publish -p ${PKG_NAME}

0 commit comments

Comments
 (0)