Skip to content

Commit 589a1f5

Browse files
author
Søren Hansen
authored
ci: Create release CI (#26)
1 parent 13109b8 commit 589a1f5

3 files changed

Lines changed: 115 additions & 3 deletions

File tree

.github/workflows/lint_pr.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: Lint PR
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
main:
8+
name: Validate PR title
9+
runs-on: ubuntu-latest
10+
permissions:
11+
pull-requests: read
12+
steps:
13+
- uses: amannn/action-semantic-pull-request@v5
14+
env:
15+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release-plz.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Release-plz
2+
3+
permissions:
4+
pull-requests: write
5+
contents: write
6+
7+
on:
8+
push:
9+
branches:
10+
- main
11+
12+
jobs:
13+
14+
# Release unpublished packages.
15+
release-plz-release:
16+
name: Release-plz release
17+
runs-on: ubuntu-latest
18+
permissions:
19+
contents: write
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 0
25+
- name: Install Rust toolchain
26+
uses: dtolnay/rust-toolchain@stable
27+
- name: Run release-plz
28+
uses: release-plz/action@v0.5
29+
with:
30+
manifest_path: squeeel_cli/Cargo.toml
31+
command: release
32+
env:
33+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
35+
36+
# Create a PR with the new versions and changelog, preparing the next release.
37+
release-plz-pr:
38+
name: Release-plz PR
39+
runs-on: ubuntu-latest
40+
permissions:
41+
contents: write
42+
pull-requests: write
43+
concurrency:
44+
group: release-plz-${{ github.ref }}
45+
cancel-in-progress: false
46+
steps:
47+
- name: Checkout repository
48+
uses: actions/checkout@v4
49+
with:
50+
fetch-depth: 0
51+
- name: Install Rust toolchain
52+
uses: dtolnay/rust-toolchain@stable
53+
- name: Run release-plz
54+
id: release-plz
55+
uses: release-plz/action@v0.5
56+
with:
57+
manifest_path: squeeel_cli/Cargo.toml
58+
command: release-pr
59+
env:
60+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
61+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
62+
- name: Update README in the release PR
63+
env:
64+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
65+
PR: ${{ steps.release-plz.outputs.pr }}
66+
run: |
67+
set -e
68+
69+
new_version=${{ fromJSON(steps.release-plz.outputs.pr).releases[0].version }}
70+
pr_number=${{ fromJSON(steps.release-plz.outputs.pr).number }}
71+
if [[ -n "$pr_number" ]]; then
72+
gh pr checkout $pr_number
73+
cd npm-package
74+
npm config set version=$new_version
75+
git add .
76+
git commit -m "Update npm-package version"
77+
git push
78+
fi

.github/workflows/release_rust.yml

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
on:
22
push:
33
tags:
4-
- "rust_v*" # Run when tag matches rust_v*, i.e. rust_v1.0, rust_v20.15.10
4+
- "squeeel-cli-v*" # Run when tag matches squeeel-cli-v*, i.e. squeeel-cli-v1.0, squeeel-cli-v20.15.10
55

66
name: Release Rust Binary
77

@@ -160,8 +160,8 @@ jobs:
160160
env:
161161
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
162162
with:
163-
tag_name: rust_${{ steps.get_version.outputs.VERSION }}
164-
release_name: ${{ steps.get_version.outputs.VERSION }}
163+
tag_name: squeeel-cli-${{ steps.get_version.outputs.VERSION }}
164+
release_name: squeeel-${{ steps.get_version.outputs.VERSION }}
165165

166166
- name: Download Linux tarball
167167
uses: actions/download-artifact@v4
@@ -207,3 +207,22 @@ jobs:
207207
asset_path: ./${{ env.RELEASE_BIN }}-${{ steps.get_version.outputs.VERSION }}-${{ env.MACOS_TARGET }}.tar.gz
208208
asset_content_type: application/gzip
209209
asset_name: ${{ env.RELEASE_BIN }}-${{ steps.get_version.outputs.VERSION }}-${{ env.MACOS_TARGET }}.tar.gz
210+
211+
release-npm:
212+
name: npm Release
213+
needs: release
214+
runs-on: ubuntu-latest
215+
steps:
216+
- uses: actions/checkout@v4
217+
- uses: actions/setup-node@v4
218+
with:
219+
node-version: '22.x'
220+
registry-url: 'https://registry.npmjs.org'
221+
- name: Npm install
222+
working-directory: npm-package
223+
run: npm ci
224+
- name: Publish
225+
working-directory: npm-package
226+
run: npm publish
227+
env:
228+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

0 commit comments

Comments
 (0)