Skip to content

Commit 271f673

Browse files
committed
Modernize release and repo workflows
1 parent 50139ca commit 271f673

70 files changed

Lines changed: 2796 additions & 1401 deletions

Some content is hidden

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

.github/release.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
changelog:
2+
exclude:
3+
labels:
4+
- ignore-for-release
5+
authors:
6+
- github-actions[bot]
7+
categories:
8+
- title: Breaking Changes
9+
labels:
10+
- breaking-change
11+
- semver-major
12+
- title: Features
13+
labels:
14+
- enhancement
15+
- feature
16+
- semver-minor
17+
- title: Fixes
18+
labels:
19+
- bug
20+
- fix
21+
- semver-patch
22+
- title: Maintenance
23+
labels:
24+
- dependencies
25+
- documentation
26+
- maintenance
27+
- title: Other Changes
28+
labels:
29+
- "*"

.github/workflows/build-test-branch.yml

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ concurrency:
1616

1717
jobs:
1818
build-test:
19-
name: Build build-test
19+
name: Bundle build-test
2020
runs-on: ubuntu-latest
2121

2222
steps:
@@ -59,10 +59,7 @@ jobs:
5959
build-test:refs/remotes/origin/build-test
6060
6161
- name: Check release versions are consistent
62-
run: scripts/check-version.sh
63-
64-
- name: Check dev release version is incremented from main
65-
run: scripts/check-version.sh --incremented-from origin/main
62+
run: scripts/release/check-version.sh
6663

6764
- name: Install Python dependencies
6865
run: |
@@ -76,32 +73,32 @@ jobs:
7673
npm ci --prefix docs
7774
7875
- name: Check dev symlink layout
79-
run: scripts/dev.sh --check
76+
run: scripts/dev/setup-symlinks.sh --check
8077

8178
- name: Create local build-test branch
8279
run: git checkout -B build-test "$GITHUB_SHA"
8380

84-
- name: Build production outputs
85-
run: scripts/build.sh --clean
81+
- name: Bundle production outputs
82+
run: scripts/bundle/bundle.sh --clean
8683

87-
- name: Validate production build layout
88-
run: scripts/check/check-builds.sh
84+
- name: Validate production bundle layout
85+
run: scripts/github-workflows/check-builds.sh
8986

9087
- name: Run code tests
91-
run: scripts/test.sh
88+
run: scripts/test/test.sh
9289

93-
- name: Commit build artifacts
90+
- name: Commit bundle artifacts
9491
id: commit
9592
run: |
9693
git config user.name "github-actions[bot]"
9794
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
9895
git add -A
9996
if git diff --cached --quiet; then
100-
echo "No build artifact changes to commit."
97+
echo "No bundle artifact changes to commit."
10198
echo "committed=false" >> "$GITHUB_OUTPUT"
10299
exit 0
103100
fi
104-
git commit -m "Build artifacts for ${GITHUB_SHA}"
101+
git commit -m "Bundle artifacts for ${GITHUB_SHA}"
105102
echo "committed=true" >> "$GITHUB_OUTPUT"
106103
107104
- name: Push build-test branch
@@ -112,7 +109,7 @@ jobs:
112109
env:
113110
GH_TOKEN: ${{ github.token }}
114111
run: |
115-
for workflow in test.yml check-builds.yml check-version.yml; do
112+
for workflow in test.yml check-builds.yml check-version.yml release-tag.yml; do
116113
curl --fail --show-error --silent \
117114
-X POST \
118115
-H "Authorization: Bearer $GH_TOKEN" \

.github/workflows/check-builds.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@ jobs:
3535
npm ci --prefix packages/cadjs
3636
npm ci --prefix viewer
3737
38-
- name: Check production build outputs
39-
run: scripts/check/check-builds.sh
38+
- name: Check production bundle outputs
39+
run: scripts/github-workflows/check-builds.sh
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Check Symlinks
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
branches:
7+
- dev
8+
push:
9+
branches:
10+
- dev
11+
12+
jobs:
13+
check-symlinks:
14+
name: Check Symlinks
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Check out repository
19+
uses: actions/checkout@v4
20+
21+
- name: Check development symlinks
22+
run: scripts/github-workflows/check-symlinks.sh

.github/workflows/check-version.yml

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -33,26 +33,4 @@ jobs:
3333
run: git fetch --no-tags origin main:refs/remotes/origin/main dev:refs/remotes/origin/dev
3434

3535
- name: Check release version
36-
env:
37-
CURRENT_REF_NAME: ${{ github.ref_name }}
38-
PULL_REQUEST_BASE_SHA: ${{ github.event.pull_request.base.sha }}
39-
PUSH_BEFORE_SHA: ${{ github.event.before }}
40-
run: |
41-
if [ "$GITHUB_EVENT_NAME" = "pull_request" ]; then
42-
base_ref="$PULL_REQUEST_BASE_SHA"
43-
elif [ "$CURRENT_REF_NAME" = "dev" ]; then
44-
if [ -n "$PUSH_BEFORE_SHA" ] && [ "$PUSH_BEFORE_SHA" != "0000000000000000000000000000000000000000" ]; then
45-
base_ref="$PUSH_BEFORE_SHA"
46-
else
47-
base_ref="origin/main"
48-
fi
49-
elif [ "$CURRENT_REF_NAME" = "build-test" ]; then
50-
base_ref="origin/main"
51-
else
52-
base_ref="$PUSH_BEFORE_SHA"
53-
fi
54-
if [ -z "$base_ref" ] || [ "$base_ref" = "0000000000000000000000000000000000000000" ]; then
55-
scripts/check-version.sh
56-
else
57-
scripts/check-version.sh --incremented-from "$base_ref"
58-
fi
36+
run: scripts/release/check-version.sh
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
name: Prepare Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
bump:
7+
description: Semver part to bump when set_version is empty.
8+
required: true
9+
default: patch
10+
type: choice
11+
options:
12+
- patch
13+
- minor
14+
- major
15+
set_version:
16+
description: Exact X.Y.Z version to release instead of bumping.
17+
required: false
18+
type: string
19+
base_branch:
20+
description: Branch to open the release PR against.
21+
required: true
22+
default: dev
23+
type: string
24+
dry_run:
25+
description: Show the planned release PR changes without pushing.
26+
required: true
27+
default: false
28+
type: boolean
29+
30+
permissions:
31+
contents: write
32+
pull-requests: write
33+
34+
concurrency:
35+
group: prepare-release-${{ inputs.base_branch }}
36+
cancel-in-progress: false
37+
38+
jobs:
39+
prepare-release:
40+
name: Prepare Release PR
41+
runs-on: ubuntu-latest
42+
43+
steps:
44+
- name: Check out base branch
45+
uses: actions/checkout@v4
46+
with:
47+
ref: ${{ inputs.base_branch }}
48+
fetch-depth: 0
49+
50+
- name: Set up Python
51+
uses: actions/setup-python@v5
52+
with:
53+
python-version: "3.12"
54+
55+
- name: Fetch release comparison refs
56+
run: |
57+
git fetch --tags origin
58+
git fetch --no-tags origin main:refs/remotes/origin/main
59+
60+
- name: Prepare version metadata
61+
id: version
62+
env:
63+
BUMP: ${{ inputs.bump }}
64+
SET_VERSION: ${{ inputs.set_version }}
65+
run: |
66+
if [ -n "$SET_VERSION" ]; then
67+
scripts/release/bump-version.sh --set-version "$SET_VERSION" --no-commit
68+
else
69+
scripts/release/bump-version.sh "$BUMP" --no-commit
70+
fi
71+
version="$(tr -d '[:space:]' < plugins/cad/VERSION)"
72+
echo "version=$version" >> "$GITHUB_OUTPUT"
73+
74+
- name: Check release metadata
75+
run: |
76+
scripts/release/check-version.sh --incremented-from origin/main
77+
latest_tag="$(git tag --list '[0-9]*.[0-9]*.[0-9]*' --sort=-version:refname | head -n 1 || true)"
78+
if [ -n "$latest_tag" ]; then
79+
scripts/release/check-version.sh --incremented-from "refs/tags/$latest_tag"
80+
fi
81+
82+
- name: Check dev symlink layout
83+
run: scripts/dev/setup-symlinks.sh --check
84+
85+
- name: Show dry-run diff
86+
if: inputs.dry_run
87+
run: |
88+
git diff --stat
89+
git diff -- plugins/cad/VERSION AGENTS.md CONTRIBUTING.md scripts/README.md
90+
91+
- name: Create release pull request
92+
if: ${{ !inputs.dry_run }}
93+
env:
94+
GH_TOKEN: ${{ github.token }}
95+
BASE_BRANCH: ${{ inputs.base_branch }}
96+
VERSION: ${{ steps.version.outputs.version }}
97+
run: |
98+
branch="release/$VERSION"
99+
git config user.name "github-actions[bot]"
100+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
101+
git checkout -B "$branch"
102+
git add -A
103+
if git diff --cached --quiet; then
104+
echo "No release metadata changes to commit."
105+
exit 0
106+
fi
107+
git commit -m "Release $VERSION"
108+
git push --force-with-lease origin "$branch"
109+
if gh pr view "$branch" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then
110+
gh pr edit "$branch" \
111+
--repo "$GITHUB_REPOSITORY" \
112+
--title "Release $VERSION" \
113+
--body "Bumps repo-owned release metadata to $VERSION. Merging this PR lets the production branch builder materialize generated outputs and the release-tag workflow create the GitHub tag and draft release."
114+
else
115+
gh pr create \
116+
--repo "$GITHUB_REPOSITORY" \
117+
--base "$BASE_BRANCH" \
118+
--head "$branch" \
119+
--title "Release $VERSION" \
120+
--body "Bumps repo-owned release metadata to $VERSION. Merging this PR lets the production branch builder materialize generated outputs and the release-tag workflow create the GitHub tag and draft release."
121+
fi

.github/workflows/release-tag.yml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: Release Tag
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
dry_run:
7+
description: Validate and show tag/release actions without writing.
8+
required: true
9+
default: false
10+
type: boolean
11+
publish:
12+
description: Publish the GitHub Release instead of leaving it as a draft.
13+
required: true
14+
default: false
15+
type: boolean
16+
create_release:
17+
description: Create the GitHub Release after pushing the tag.
18+
required: true
19+
default: true
20+
type: boolean
21+
push:
22+
branches:
23+
# Temporary production branch while the release flow is proven.
24+
# Switch this to main when build-test is retired.
25+
- build-test
26+
27+
permissions:
28+
contents: write
29+
30+
concurrency:
31+
group: release-tag-${{ github.ref_name }}
32+
cancel-in-progress: false
33+
34+
jobs:
35+
release-tag:
36+
name: Tag And Draft Release
37+
runs-on: ubuntu-latest
38+
39+
steps:
40+
- name: Check out release branch
41+
uses: actions/checkout@v4
42+
with:
43+
fetch-depth: 0
44+
fetch-tags: true
45+
46+
- name: Set up Python
47+
uses: actions/setup-python@v5
48+
with:
49+
python-version: "3.12"
50+
51+
- name: Set up Node.js
52+
uses: actions/setup-node@v4
53+
with:
54+
node-version: "22"
55+
56+
- name: Install Node dependencies
57+
run: |
58+
npm ci --prefix packages/cadjs
59+
npm ci --prefix viewer
60+
61+
- name: Validate production bundle layout
62+
run: scripts/github-workflows/check-builds.sh
63+
64+
- name: Create release tag and GitHub Release
65+
env:
66+
GH_TOKEN: ${{ github.token }}
67+
INPUT_DRY_RUN: ${{ github.event_name == 'workflow_dispatch' && inputs.dry_run || false }}
68+
INPUT_PUBLISH: ${{ github.event_name == 'workflow_dispatch' && inputs.publish || false }}
69+
INPUT_CREATE_RELEASE: ${{ github.event_name != 'workflow_dispatch' || inputs.create_release }}
70+
SKIP_EXISTING_VERSION: ${{ github.event_name == 'push' }}
71+
run: |
72+
args=()
73+
if [ "$INPUT_DRY_RUN" = "true" ]; then
74+
args+=(--dry-run)
75+
fi
76+
if [ "$INPUT_PUBLISH" = "true" ]; then
77+
args+=(--publish)
78+
fi
79+
if [ "$INPUT_CREATE_RELEASE" != "true" ]; then
80+
args+=(--skip-release)
81+
fi
82+
if [ "$SKIP_EXISTING_VERSION" = "true" ]; then
83+
args+=(--skip-existing-version)
84+
fi
85+
scripts/release/publish-github-release.sh "${args[@]}"

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
4646
- name: Check dev layout
4747
if: github.ref_name == 'dev' || github.base_ref == 'dev'
48-
run: scripts/dev.sh --check
48+
run: scripts/dev/setup-symlinks.sh --check
4949

5050
- name: Run code tests
51-
run: scripts/test.sh
51+
run: scripts/test/test.sh

0 commit comments

Comments
 (0)