|
1 | 1 | name: Publish Tier 1 |
2 | 2 |
|
3 | 3 | on: |
4 | | - workflow_run: |
5 | | - workflows: ["Release"] |
6 | | - types: [completed] |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'Release/[0-9]+.[0-9]+.[0-9]+*' |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + version: |
| 10 | + description: 'Version to publish (e.g., 0.11.0-beta)' |
| 11 | + required: true |
| 12 | + type: string |
7 | 13 |
|
8 | 14 | permissions: |
9 | | - contents: read |
| 15 | + contents: write |
| 16 | + pull-requests: write |
10 | 17 | id-token: write |
11 | 18 |
|
12 | 19 | jobs: |
| 20 | + prepare: |
| 21 | + runs-on: ubuntu-latest |
| 22 | + outputs: |
| 23 | + version: ${{ steps.version.outputs.VERSION }} |
| 24 | + steps: |
| 25 | + - name: Checkout repository |
| 26 | + uses: actions/checkout@v4 |
| 27 | + with: |
| 28 | + fetch-depth: 0 |
| 29 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 30 | + |
| 31 | + - name: Validate tag is on main (tag push only) |
| 32 | + if: github.event_name == 'push' |
| 33 | + run: | |
| 34 | + git fetch origin main |
| 35 | + if ! git merge-base --is-ancestor ${{ github.sha }} origin/main; then |
| 36 | + echo "::error::Release tag must be created from main branch!" |
| 37 | + exit 1 |
| 38 | + fi |
| 39 | +
|
| 40 | + - name: Extract version |
| 41 | + id: version |
| 42 | + run: | |
| 43 | + if [ "${{ github.event_name }}" = "push" ]; then |
| 44 | + echo "VERSION=${GITHUB_REF#refs/tags/Release/}" >> $GITHUB_OUTPUT |
| 45 | + else |
| 46 | + echo "VERSION=${{ inputs.version }}" >> $GITHUB_OUTPUT |
| 47 | + fi |
| 48 | +
|
| 49 | + - name: Validate changelogs have version entries |
| 50 | + run: | |
| 51 | + VERSION="${{ steps.version.outputs.VERSION }}" |
| 52 | + # Escape dots for regex matching (1.2.3 -> 1\.2\.3) |
| 53 | + VERSION_ESCAPED=$(echo "$VERSION" | sed 's/\./\\./g') |
| 54 | + PACKAGES=( |
| 55 | + "dart_logging" |
| 56 | + "dart_node_core" |
| 57 | + "dart_node_coverage" |
| 58 | + "reflux" |
| 59 | + "dart_node_express" |
| 60 | + "dart_node_ws" |
| 61 | + "dart_node_better_sqlite3" |
| 62 | + "dart_node_mcp" |
| 63 | + "dart_node_react" |
| 64 | + "dart_node_react_native" |
| 65 | + ) |
| 66 | + MISSING=() |
| 67 | + for pkg in "${PACKAGES[@]}"; do |
| 68 | + CHANGELOG="packages/$pkg/CHANGELOG.md" |
| 69 | + if [[ ! -f "$CHANGELOG" ]]; then |
| 70 | + echo "::error::Missing CHANGELOG.md for $pkg" |
| 71 | + MISSING+=("$pkg (no CHANGELOG.md)") |
| 72 | + continue |
| 73 | + fi |
| 74 | + # Check for ## X.Y.Z or ## X.Y.Z-prerelease header |
| 75 | + if ! grep -qE "^## $VERSION_ESCAPED\b" "$CHANGELOG"; then |
| 76 | + echo "::error::$pkg/CHANGELOG.md missing entry for version $VERSION" |
| 77 | + MISSING+=("$pkg") |
| 78 | + fi |
| 79 | + done |
| 80 | + if [[ ${#MISSING[@]} -gt 0 ]]; then |
| 81 | + echo "::error::Changelogs missing version $VERSION: ${MISSING[*]}" |
| 82 | + exit 1 |
| 83 | + fi |
| 84 | + echo "All changelogs have entries for version $VERSION" |
| 85 | +
|
| 86 | + - name: Setup Dart |
| 87 | + uses: ./.github/actions/setup |
| 88 | + with: |
| 89 | + dart-version: ${{ vars.DART_VERSION }} |
| 90 | + |
| 91 | + - name: Prepare for publishing (switch to pub.dev deps) |
| 92 | + run: dart run tools/prepare_publish.dart ${{ steps.version.outputs.VERSION }} |
| 93 | + |
| 94 | + - name: Create release branch and commit |
| 95 | + run: | |
| 96 | + git config user.name "github-actions[bot]" |
| 97 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 98 | + git checkout -b release/${{ steps.version.outputs.VERSION }} |
| 99 | + git add -A |
| 100 | + git commit -m "chore: prepare release ${{ steps.version.outputs.VERSION }} with pub.dev dependencies" |
| 101 | + git push origin release/${{ steps.version.outputs.VERSION }} |
| 102 | +
|
| 103 | + - name: Create PR to main |
| 104 | + env: |
| 105 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 106 | + run: | |
| 107 | + gh pr create \ |
| 108 | + --title "Release ${{ steps.version.outputs.VERSION }}" \ |
| 109 | + --body "## Release ${{ steps.version.outputs.VERSION }} |
| 110 | +
|
| 111 | + This PR is auto-created from the release tag. |
| 112 | +
|
| 113 | + **Do not merge yet!** Publishing happens in tier workflows (tier1 → tier2 → tier3). |
| 114 | +
|
| 115 | + After tier3 completes, dependencies will be switched back to local and this PR will be updated. |
| 116 | +
|
| 117 | + ### Publishing Tiers |
| 118 | + - Tier 1: dart_logging, dart_node_core, dart_node_coverage (this workflow) |
| 119 | + - Tier 2: reflux, dart_node_express, dart_node_ws, dart_node_better_sqlite3, dart_node_mcp |
| 120 | + - Tier 3: dart_node_react, dart_node_react_native" \ |
| 121 | + --base main \ |
| 122 | + --head release/${{ steps.version.outputs.VERSION }} |
| 123 | +
|
13 | 124 | publish: |
14 | | - if: ${{ github.event.workflow_run.conclusion == 'success' }} |
15 | | - uses: ./.github/workflows/_publish-packages.yml |
16 | | - with: |
17 | | - tier: 1 |
18 | | - packages: "dart_logging dart_node_core" |
19 | | - environment: pub.dev-tier1 |
20 | | - secrets: inherit |
| 125 | + needs: prepare |
| 126 | + runs-on: ubuntu-latest |
| 127 | + environment: pub.dev-tier1 |
| 128 | + steps: |
| 129 | + - uses: actions/checkout@v4 |
| 130 | + with: |
| 131 | + fetch-depth: 0 |
| 132 | + |
| 133 | + - name: Checkout release branch |
| 134 | + run: | |
| 135 | + git fetch origin "release/${{ needs.prepare.outputs.version }}" |
| 136 | + git checkout "release/${{ needs.prepare.outputs.version }}" |
| 137 | +
|
| 138 | + - uses: ./.github/actions/setup |
| 139 | + with: |
| 140 | + dart-version: ${{ vars.DART_VERSION }} |
| 141 | + |
| 142 | + - name: Publish packages |
| 143 | + run: | |
| 144 | + chmod +x .github/scripts/publish-packages.sh |
| 145 | + .github/scripts/publish-packages.sh "${{ needs.prepare.outputs.version }}" dart_logging dart_node_core dart_node_coverage |
0 commit comments