Skip to content

Commit 49e93a7

Browse files
committed
chore: try a new set of workflows for releasing
1 parent 208f277 commit 49e93a7

File tree

15 files changed

+325
-183
lines changed

15 files changed

+325
-183
lines changed

.github/workflows/auto-merge.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
- opened
66
- reopened
77
- ready_for_review
8+
- labeled
89
jobs:
910
enableAutoMerge:
1011
name: 'Set AutoMerge on PR #${{ github.event.number }}'
@@ -17,4 +18,4 @@ jobs:
1718
with:
1819
token: ${{ secrets.PROJEN_GITHUB_TOKEN }}
1920
pull-request-number: ${{ github.event.number }}
20-
merge-method: squash
21+
merge-method: ${{ contains(github.event.pull_request.labels.*.name, 'pr/no-squash') && 'merge' || 'squash' }}

.github/workflows/release-sync.yml

Lines changed: 73 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: sync-release-branch
1+
name: Daily Release Check
22

33
on:
44
workflow_dispatch: {}
@@ -11,9 +11,77 @@ jobs:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- name: Checkout repository
14-
uses: actions/checkout@main
15-
- name: Push to release branch
16-
uses: connor-baer/action-sync-branch@main
14+
uses: actions/checkout@v4
1715
with:
18-
branch: release
16+
ref: main
1917
token: ${{ secrets.PROJEN_GITHUB_TOKEN }}
18+
19+
- name: 🦀 Install Rust
20+
uses: actions-rust-lang/setup-rust-toolchain@v1
21+
22+
- name: ⚡ Cache
23+
uses: actions/cache@v4
24+
with:
25+
path: |
26+
~/.cargo/registry
27+
~/.cargo/git
28+
target
29+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
30+
restore-keys: |
31+
${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
32+
${{ runner.os }}-cargo
33+
34+
- name: Install cargo-release
35+
uses: baptiste0928/cargo-install@v3
36+
with:
37+
crate: cargo-release
38+
39+
- name: Prepare git identity
40+
run: |
41+
git config --global user.email "[email protected]"
42+
git config --global user.name "cdklabs-automation"
43+
44+
- name: Check if there are commits to release
45+
id: check_commits
46+
run: |
47+
git fetch origin release
48+
if [[ "$(git rev-list -n1 origin/release..HEAD)" != "" ]]; then
49+
echo "has_commits=true" >> $GITHUB_OUTPUT
50+
else
51+
echo "has_commits=false" >> $GITHUB_OUTPUT
52+
fi
53+
54+
- name: Wat
55+
run: git log -n 3
56+
57+
- name: Bump package versions and commit
58+
if: steps.check_commits.outputs.has_commits == 'true'
59+
run: |
60+
cargo release --all-features --verbose minor --execute --no-confirm --no-push --no-tag --no-publish
61+
62+
- name: After
63+
run: git log -n 3
64+
65+
- name: Determine commit message
66+
id: commit
67+
if: steps.check_commits.outputs.has_commits == 'true'
68+
run: |
69+
echo "title=$(git log --format=%B -n 1)" >> $GITHUB_OUTPUT
70+
71+
# We push the branch ourselves, otherwise peter-evans/create-pull-request will
72+
# cherry-pick our top commit onto `release`, which is not what we want.
73+
- name: Push the branch
74+
if: steps.check_commits.outputs.has_commits == 'true'
75+
run: |
76+
git push -f origin HEAD:github-actions/release
77+
git checkout github-actions/release
78+
79+
- name: Open release pull request
80+
if: steps.check_commits.outputs.has_commits == 'true'
81+
run: |
82+
env GITHUB_TOKEN=${{ secrets.PROJEN_GITHUB_TOKEN }} gh pr create \
83+
--title "${{ steps.commit.outputs.title }}" \
84+
--fill \
85+
--base release \
86+
--label auto-approve \
87+
--label pr/no-squash

.github/workflows/release.yml

Lines changed: 48 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,78 @@
11
# .github/workflows/release.yml
2+
name: Release from release branch
23

3-
name: release
44
on:
5+
workflow_dispatch: {}
56
push:
67
branches:
78
- release
89

10+
env:
11+
RELEASE_BRANCH: release
12+
MERGEBACK_BRANCH: github-actions/mergeback
13+
914
jobs:
10-
release_to_crates:
11-
name: Release to crates.io
15+
create_mergeback:
16+
name: Create the merge-back PR
1217
runs-on: ubuntu-latest
1318
steps:
14-
- name: Checkout
15-
uses: actions/checkout@main
16-
with:
17-
token: ${{ secrets.PROJEN_GITHUB_TOKEN }}
18-
- name: Set git identity
19-
run: |-
20-
git config user.name "cdklabs-automation"
21-
git config user.email "[email protected]"
22-
- name: Install cargo-release
23-
uses: taiki-e/install-action@main
24-
with:
25-
tool: cargo-binstall
26-
- run: cargo binstall --no-confirm cargo-release
27-
- run: cargo release --all-features --verbose minor --execute --no-confirm --no-push
28-
- name: Open pull request
29-
id: create-pr
30-
uses: peter-evans/create-pull-request@v7
19+
- name: Checkout repository
20+
uses: actions/checkout@v4
3121
with:
22+
ref: ${{ env.RELEASE_BRANCH }}
3223
token: ${{ secrets.PROJEN_GITHUB_TOKEN }}
33-
author: cdklabs-automation <[email protected]>
34-
committer: cdklabs-automation <[email protected]>
35-
signoff: true
36-
branch: github-actions/release
37-
base: main
38-
body: |
39-
release: <%= crate.name %> v<%= version.actual %>
4024

41-
[Workflow Run]: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
42-
commit-message: |-
43-
release: <%= crate.name %> v<%= version.actual %>
25+
- name: Open merge-back pull request
26+
run: |
27+
git push -f origin HEAD:${{ env.MERGEBACK_BRANCH }}
28+
git checkout ${{ env.MERGEBACK_BRANCH }}
4429
45-
[Workflow Run]: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
46-
47-
title: |
48-
release: <%= crate.name %> v<%= version.actual %>
49-
labels: auto-approve
50-
- name: Push New Tag
51-
run: git push origin --tags
52-
env:
53-
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_TOKEN }}
30+
env GITHUB_TOKEN=${{ secrets.PROJEN_GITHUB_TOKEN }} gh pr create \
31+
--title "chore: merge-back" \
32+
--fill \
33+
--base main \
34+
--label auto-approve \
35+
--label pr/no-squash
5436
5537
release_to_npm:
56-
name: Release to npm
57-
needs: release_to_crates
38+
name: Release to NPM
5839
runs-on: ubuntu-latest
5940
steps:
6041
- name: Checkout
61-
uses: actions/checkout@main
42+
uses: actions/checkout@v4
6243
with:
63-
ref: github-actions/release
44+
ref: ${{ env.RELEASE_BRANCH }}
45+
token: ${{ secrets.PROJEN_GITHUB_TOKEN }}
46+
6447
- name: Setup Node.js
6548
uses: actions/setup-node@main
6649
with:
67-
node-version: latest
68-
- uses: jetli/[email protected]
69-
name: Install wasm-pack
50+
node-version: lts/*
51+
52+
- name: 🦀 Install Rust
53+
uses: actions-rust-lang/setup-rust-toolchain@v1
54+
55+
- name: ⚡ Cache
56+
uses: actions/cache@v4
7057
with:
71-
version: latest
58+
path: |
59+
~/.cargo/registry
60+
~/.cargo/git
61+
target
62+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
63+
restore-keys: |
64+
${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
65+
${{ runner.os }}-cargo
66+
67+
- name: Install wasm-pack
68+
uses: baptiste0928/cargo-install@v3
69+
with:
70+
crate: wasm-pack
71+
7272
- name: Prepare Release
7373
run: |-
7474
wasm-pack build --all-features --target=nodejs --out-name=index
75+
7576
- name: Release
7677
run: |-
7778
npm set "//registry.npmjs.org/:_authToken" ${{ secrets.NPM_TOKEN }}

.github/workflows/security-audit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
audit:
99
runs-on: ubuntu-latest
1010
steps:
11-
- uses: actions/checkout@main
11+
- uses: actions/checkout@v4
1212
- uses: rustsec/audit-check@v2
1313
with:
1414
token: ${{ secrets.PROJEN_GITHUB_TOKEN }}

.github/workflows/status-checks.yml

Lines changed: 58 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
merge_group:
77
branches:
88
- main
9+
- release
910
name: status-checks
1011

1112
jobs:
@@ -14,28 +15,29 @@ jobs:
1415
runs-on: ubuntu-latest
1516
steps:
1617
- uses: actions/checkout@v4
17-
- uses: actions-rs/toolchain@v1
18-
with:
19-
profile: minimal
20-
toolchain: stable
21-
override: true
22-
components: rustfmt, clippy
23-
# Ensure build.rs has ran before we assert formatting...
24-
- name: Build
25-
uses: actions-rs/cargo@v1
26-
with:
27-
command: build
28-
args: --all-features
29-
- name: Check formatting
30-
uses: actions-rs/cargo@v1
18+
19+
- name: 🦀 Install Rust
20+
uses: actions-rust-lang/setup-rust-toolchain@v1
21+
22+
- name: ⚡ Cache
23+
uses: actions/cache@v4
3124
with:
32-
command: fmt
33-
args: --manifest-path ./Cargo.toml --all -- --check
34-
- name: Run clippy
35-
uses: actions-rs/cargo@v1
25+
path: |
26+
~/.cargo/registry
27+
~/.cargo/git
28+
target
29+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
30+
restore-keys: |
31+
${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
32+
${{ runner.os }}-cargo
33+
34+
- name: Install just
35+
uses: baptiste0928/cargo-install@v3
3636
with:
37-
command: clippy
38-
args: --manifest-path ./Cargo.toml -- -Adead-code -D warnings
37+
crate: just
38+
39+
- name: Run lint
40+
run: just lint
3941

4042
security_audit:
4143
name: Security Audit
@@ -56,26 +58,57 @@ jobs:
5658
id-token: write
5759
steps:
5860
- uses: actions/checkout@v4
59-
- name: Install Rust
60-
run: rustup update stable
61-
- name: Install cargo-llvm-cov
62-
uses: taiki-e/install-action@cargo-llvm-cov
61+
62+
- name: 🦀 Install Rust
63+
uses: actions-rust-lang/setup-rust-toolchain@v1
64+
65+
- name: ⚡ Cache
66+
uses: actions/cache@v4
67+
with:
68+
path: |
69+
~/.cargo/registry
70+
~/.cargo/git
71+
target
72+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
73+
restore-keys: |
74+
${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
75+
${{ runner.os }}-cargo
76+
77+
- name: Install just
78+
uses: baptiste0928/cargo-install@v3
79+
with:
80+
crate: just
81+
82+
- name: Install wasm-pack
83+
uses: baptiste0928/cargo-install@v3
84+
with:
85+
crate: cargo-llvm-cov
86+
6387
- name: Install Java 17
6488
uses: actions/setup-java@v4
6589
with:
6690
distribution: corretto
6791
java-version: 17
92+
6893
- name: Install Dotnet 8
6994
uses: actions/setup-dotnet@v4
7095
with:
7196
dotnet-version: "8.0.110"
97+
98+
- name: Try to fix .NET issue
99+
# https://github.com/dotnet/runtime/issues/91987
100+
run: |
101+
sudo rm -rf /tmp/.dotnet
102+
72103
- name: Tests with Coverage
73-
run: cargo llvm-cov --all-features --ignore-filename-regex '^(tests/.*\.rs|.*/tests\.rs)$' --no-fail-fast --lcov --output-path target/lcov.info
104+
run: just test-cov
105+
74106
- name: Coverage Report
75107
run: |
76108
cargo llvm-cov report --hide-instantiations --ignore-filename-regex '^(tests/.*\.rs|.*/tests\.rs)$' --codecov --output-path target/codecov.json
77109
cargo llvm-cov report --hide-instantiations --ignore-filename-regex '^(tests/.*\.rs|.*/tests\.rs)$' --html --output-dir target/coverage
78110
cargo llvm-cov report --hide-instantiations --ignore-filename-regex '^(tests/.*\.rs|.*/tests\.rs)$'
111+
79112
- name: Upload Coverage to CodeCov
80113
uses: codecov/[email protected]
81114
with:

Justfile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
alias b := build
2+
alias r := release
3+
4+
release: build test lint
5+
6+
build:
7+
cargo build --all-features
8+
9+
test *TEST:
10+
cargo test {{TEST}}
11+
12+
lint: fmt clippy
13+
14+
fmt:
15+
cargo fmt -- --version && cargo fmt --check
16+
17+
clippy:
18+
cargo clippy --tests -- -Adead-code -Dwarnings -Dclippy::dbg_macro
19+
20+
test-cov:
21+
cargo llvm-cov --all-features --ignore-filename-regex '^(tests/.*\.rs|.*/tests\.rs)$' --no-fail-fast --lcov --output-path target/lcov.info
22+
23+
install-tools:
24+
cargo install cargo-llvm-cov

0 commit comments

Comments
 (0)