Skip to content

Commit 2abba52

Browse files
Automates release publishing and finalization (#22)
## TLDR; This pull request automates the release publishing process using GitHub Actions. It streamlines the process of creating release branches, updating dependencies, and creating pull requests. ## What Does This Do? - Creates a new workflow to finalize the release, switching dependencies back to local ones after publishing. - Modifies the publish workflow to prepare the release branch and create a pull request to main. - Removes `publish_to: none` from `pubspec.yaml` files. ## Brief Details? - The "Finalize Release" workflow is triggered after the "Publish Tier 3" workflow completes successfully. It checks out the release branch, switches dependencies to local, commits, and pushes the changes. - The "Publish Release" workflow now validates that the tag is on main, extracts the version from the tag, creates a release branch, switches to pub.dev dependencies, commits and pushes the changes, and creates a pull request to main. The pull request body contains instructions to not merge until publishing is complete. - The workflows now use the `setup` action to setup Dart. ## How Do The Tests Prove The Change Works? There are no specific tests included in this pull request, but the workflows themselves serve as integration tests, ensuring that the release process is automated and functions as expected.
1 parent 7f6a0ce commit 2abba52

10 files changed

Lines changed: 82 additions & 40 deletions

File tree

.github/workflows/_publish-packages.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ jobs:
5050
git fetch origin "$BRANCH"
5151
git checkout "$BRANCH"
5252
53-
- uses: dart-lang/setup-dart@v1
53+
- uses: ./.github/actions/setup
5454
with:
55-
sdk: ${{ vars.DART_VERSION }}
55+
dart-version: ${{ vars.DART_VERSION }}
5656

5757
- name: Verify prerequisite packages on pub.dev
5858
if: inputs.tier > 1
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Finalize Release
2+
3+
on:
4+
workflow_run:
5+
workflows: ["Publish Tier 3"]
6+
types: [completed]
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
finalize:
13+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
token: ${{ secrets.GITHUB_TOKEN }}
21+
22+
- name: Get version from triggering tag
23+
id: version
24+
run: |
25+
git fetch --tags
26+
TAG=$(git tag --points-at ${{ github.event.workflow_run.head_sha }} | grep '^Release/' | head -1)
27+
if [ -z "$TAG" ]; then
28+
echo "::error::No Release tag found at commit ${{ github.event.workflow_run.head_sha }}"
29+
exit 1
30+
fi
31+
VERSION="${TAG#Release/}"
32+
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
33+
echo "Found tag: $TAG, version: $VERSION"
34+
35+
- name: Checkout release branch
36+
run: |
37+
BRANCH="release/${{ steps.version.outputs.VERSION }}"
38+
git fetch origin "$BRANCH"
39+
git checkout "$BRANCH"
40+
41+
- name: Setup Dart
42+
uses: ./.github/actions/setup
43+
with:
44+
dart-version: ${{ vars.DART_VERSION }}
45+
46+
- name: Switch dependencies to local
47+
run: dart run tools/switch_deps.dart local
48+
49+
- name: Commit local dependencies to release branch
50+
run: |
51+
git config user.name "github-actions[bot]"
52+
git config user.email "github-actions[bot]@users.noreply.github.com"
53+
git add -A
54+
if git diff --staged --quiet; then
55+
echo "No changes to commit"
56+
else
57+
git commit -m "chore: switch to local dependencies after publish"
58+
git push origin release/${{ steps.version.outputs.VERSION }}
59+
fi

.github/workflows/publish-release.yml

Lines changed: 20 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -10,73 +10,61 @@ permissions:
1010
pull-requests: write
1111

1212
jobs:
13-
validate-and-prepare:
13+
prepare:
1414
runs-on: ubuntu-latest
15-
outputs:
16-
version: ${{ steps.version.outputs.VERSION }}
17-
branch: ${{ steps.branch.outputs.NAME }}
1815
steps:
1916
- name: Checkout repository
2017
uses: actions/checkout@v4
2118
with:
2219
fetch-depth: 0
2320
token: ${{ secrets.GITHUB_TOKEN }}
2421

25-
- name: Validate branch is main
26-
id: branch
22+
- name: Validate tag is on main
2723
run: |
2824
git fetch origin main
2925
if ! git merge-base --is-ancestor ${{ github.sha }} origin/main; then
3026
echo "::error::Release tag must be created from main branch!"
3127
exit 1
3228
fi
33-
BRANCH=$(git branch -r --contains ${{ github.sha }} | grep -E 'origin/(main|master)' | head -1 | sed 's/.*origin\///')
34-
if [ -z "$BRANCH" ]; then
35-
echo "::error::Tag must be created from main branch"
36-
exit 1
37-
fi
38-
echo "NAME=$BRANCH" >> $GITHUB_OUTPUT
3929
40-
- name: Extract version
30+
- name: Extract version from tag
4131
id: version
4232
run: echo "VERSION=${GITHUB_REF#refs/tags/Release/}" >> $GITHUB_OUTPUT
4333

44-
- name: Checkout main branch
45-
run: git checkout main
46-
4734
- name: Setup Dart
48-
uses: dart-lang/setup-dart@v1
35+
uses: ./.github/actions/setup
4936
with:
50-
sdk: ${{ vars.DART_VERSION }}
37+
dart-version: ${{ vars.DART_VERSION }}
5138

52-
- name: Create release branch
39+
- name: Prepare for publishing (switch to pub.dev deps)
40+
run: dart run tools/prepare_publish.dart ${{ steps.version.outputs.VERSION }}
41+
42+
- name: Create release branch and commit
5343
run: |
5444
git config user.name "github-actions[bot]"
5545
git config user.email "github-actions[bot]@users.noreply.github.com"
5646
git checkout -b release/${{ steps.version.outputs.VERSION }}
57-
58-
- name: Set package versions
59-
run: dart tools/prepare_publish.dart ${{ steps.version.outputs.VERSION }}
60-
61-
- name: Commit and push
62-
run: |
6347
git add -A
64-
git commit -m "chore: prepare release ${{ steps.version.outputs.VERSION }}"
48+
git commit -m "chore: prepare release ${{ steps.version.outputs.VERSION }} with pub.dev dependencies"
6549
git push origin release/${{ steps.version.outputs.VERSION }}
6650
67-
- name: Create PR
51+
- name: Create PR to main
6852
env:
6953
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7054
run: |
7155
gh pr create \
7256
--title "Release ${{ steps.version.outputs.VERSION }}" \
7357
--body "## Release ${{ steps.version.outputs.VERSION }}
7458
75-
This PR contains version bumps.
59+
This PR is auto-created from the release tag.
60+
61+
**Do not merge yet!** Publishing happens in tier workflows (tier1 → tier2 → tier3).
62+
63+
After tier3 completes, dependencies will be switched back to local and this PR will be updated.
7664
77-
### Deployment Status
78-
- [ ] Tier 1 (Core)
79-
- [ ] Tier 2 (Reflux, Express, WS, SQLite, MCP)
80-
- [ ] Tier 3 (React)" \
65+
### Publishing Tiers
66+
- Tier 1: dart_logging, dart_node_core (triggered by this workflow)
67+
- Tier 2: reflux, dart_node_express, dart_node_ws, dart_node_better_sqlite3, dart_node_mcp (20 min wait)
68+
- Tier 3: dart_node_react, dart_node_react_native (20 min wait)" \
8169
--base main \
8270
--head release/${{ steps.version.outputs.VERSION }}

.github/workflows/publish-tier1.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ jobs:
1616
with:
1717
tier: 1
1818
packages: "dart_logging dart_node_core"
19+
environment: pub.dev-tier1
1920
secrets: inherit

packages/dart_node_core/pubspec.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ name: dart_node_core
22
description: Core JS interop utilities for dart_node packages
33
version: 0.9.0-beta
44
repository: https://github.com/MelbourneDeveloper/dart_node
5-
publish_to: none
65

76
environment:
87
sdk: ^3.10.0

packages/dart_node_express/pubspec.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ name: dart_node_express
22
description: Express.js bindings for Dart
33
version: 0.9.0-beta
44
repository: https://github.com/MelbourneDeveloper/dart_node
5-
publish_to: none
65

76
environment:
87
sdk: ^3.10.0

packages/dart_node_react/pubspec.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ name: dart_node_react
22
description: React bindings for Dart
33
version: 0.9.0-beta
44
repository: https://github.com/MelbourneDeveloper/dart_node
5-
publish_to: none
65

76
environment:
87
sdk: ^3.10.0

packages/dart_node_react_native/pubspec.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ name: dart_node_react_native
22
description: React Native bindings for Dart
33
version: 0.9.0-beta
44
repository: https://github.com/MelbourneDeveloper/dart_node
5-
publish_to: none
65

76
environment:
87
sdk: ^3.10.0

packages/dart_node_ws/pubspec.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ name: dart_node_ws
22
description: WebSocket bindings for Dart on Node.js
33
version: 0.9.0-beta
44
repository: https://github.com/MelbourneDeveloper/dart_node
5-
publish_to: none
65

76
environment:
87
sdk: ^3.10.0

packages/reflux/pubspec.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ name: reflux
22
description: Predictable state container for Dart apps - inspired by Redux patterns
33
version: 0.9.0-beta
44
repository: https://github.com/MelbourneDeveloper/dart_node
5-
publish_to: none
65

76
environment:
87
sdk: ^3.10.0

0 commit comments

Comments
 (0)