|
1 | 1 | name: Publish packages |
2 | 2 | run-name: Release ${{ inputs.tag || github.ref_name }} (publish=${{ github.event_name == 'push' || inputs.publish }}) |
3 | | - |
4 | 3 | on: |
5 | 4 | push: |
6 | 5 | tags: ['v*'] |
7 | 6 | workflow_dispatch: |
8 | 7 | inputs: |
9 | 8 | tag: |
10 | | - description: Existing published release tag, such as v0.1.0 (dispatch from this tag) |
| 9 | + description: Proposed version; publish=true requires dispatch from this exact existing tag |
11 | 10 | required: true |
12 | 11 | type: string |
13 | 12 | publish: |
14 | | - description: Publish to npm after validation (false only builds and checks) |
| 13 | + description: Publish validated deliverables (false never uploads release assets or packages) |
15 | 14 | type: boolean |
16 | 15 | default: false |
17 | | - |
18 | 16 | permissions: |
19 | 17 | contents: read |
20 | | - |
21 | 18 | concurrency: |
22 | 19 | group: brokk-town-packages |
23 | 20 | cancel-in-progress: false |
24 | | - |
25 | 21 | jobs: |
26 | 22 | native: |
27 | | - if: github.event_name == 'push' |
28 | | - permissions: |
29 | | - contents: write |
30 | 23 | uses: ./.github/workflows/release.yml |
| 24 | + with: |
| 25 | + tag: ${{ inputs.tag || github.ref_name }} |
31 | 26 | packages: |
32 | 27 | needs: native |
33 | | - if: ${{ !cancelled() && (needs.native.result == 'success' || github.event_name == 'workflow_dispatch') }} |
34 | 28 | runs-on: ubuntu-latest |
35 | | - timeout-minutes: 60 |
| 29 | + timeout-minutes: 30 |
36 | 30 | environment: packages-publish |
37 | 31 | permissions: |
38 | | - contents: read |
| 32 | + actions: read |
| 33 | + contents: write |
39 | 34 | id-token: write |
| 35 | + env: |
| 36 | + GH_TOKEN: ${{ github.token }} |
| 37 | + RELEASE_COMMIT: ${{ github.sha }} |
| 38 | + RELEASE_TAG: ${{ inputs.tag || github.ref_name }} |
40 | 39 | steps: |
41 | | - - name: Require the exact release tag |
42 | | - env: |
43 | | - RELEASE_REF: ${{ github.ref }} |
44 | | - RELEASE_TAG: ${{ inputs.tag || github.ref_name }} |
45 | | - run: test "$RELEASE_REF" = "refs/tags/$RELEASE_TAG" |
46 | | - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 |
| 40 | + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 |
47 | 41 | with: |
48 | 42 | persist-credentials: false |
49 | | - - uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6.5.0 |
| 43 | + - uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 |
50 | 44 | with: |
51 | 45 | node-version: '24' |
52 | 46 | registry-url: https://registry.npmjs.org |
53 | 47 | package-manager-cache: false |
54 | | - - name: Download the published native assets |
| 48 | + - name: Require exact existing tag for publication |
| 49 | + if: github.event_name == 'push' || inputs.publish |
55 | 50 | env: |
56 | | - GH_TOKEN: ${{ github.token }} |
57 | | - GH_REPO: ${{ github.repository }} |
58 | | - RELEASE_TAG: ${{ inputs.tag || github.ref_name }} |
59 | | - run: | |
60 | | - test "$(gh release view "$RELEASE_TAG" --json isDraft --jq .isDraft)" = false |
61 | | - gh release download "$RELEASE_TAG" --dir dist/native |
62 | | - - name: Test launchers and build packages from verified assets |
| 51 | + RELEASE_REF: ${{ github.ref }} |
| 52 | + run: test "$RELEASE_REF" = "refs/tags/$RELEASE_TAG" |
| 53 | + - name: Download candidate from this exact workflow run |
63 | 54 | env: |
64 | | - RELEASE_TAG: ${{ inputs.tag || github.ref_name }} |
65 | | - run: | |
66 | | - python3 -m unittest discover -s scripts -p '*_test.py' -v |
67 | | - node --test --test-isolation=none npm/bt.test.cjs |
68 | | - python3 scripts/package_installers.py "$RELEASE_TAG" dist/native dist/packages |
69 | | - python3 scripts/smoke_installers.py --tag "$RELEASE_TAG" --assets dist/native --packages dist/packages |
70 | | - - name: Check version availability and existing package integrity |
71 | | - run: python3 scripts/package_registry.py check dist/packages |
72 | | - - name: Save validated packages for review and bootstrap publication |
73 | | - uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 |
74 | | - with: |
75 | | - name: packages-${{ inputs.tag || github.ref_name }} |
76 | | - path: dist/packages/ |
77 | | - if-no-files-found: error |
78 | | - - name: Submit validated packages |
| 55 | + RELEASE_RUN: ${{ github.run_id }} |
| 56 | + run: gh run download "$RELEASE_RUN" --repo github.com/BrokkAi/brokk-town --name "release-candidate-$RELEASE_COMMIT-$RELEASE_TAG" --dir dist/candidate |
| 57 | + - name: Check every version before any final upload |
| 58 | + run: python3 scripts/release_checks.py version |
| 59 | + - name: Validate actual publisher without publishing |
| 60 | + if: github.event_name == 'workflow_dispatch' && !inputs.publish |
| 61 | + run: python3 scripts/release_checks.py authorization |
| 62 | + - name: Recheck credentials, resume uploads, and finalize last |
79 | 63 | if: github.event_name == 'push' || inputs.publish |
80 | | - run: python3 scripts/package_registry.py publish dist/packages |
| 64 | + run: python3 scripts/publish_release.py |
0 commit comments