release #12
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: release | |
| on: | |
| # Auto-trigger after main workflow completes | |
| workflow_run: | |
| workflows: ["main"] | |
| types: [completed] | |
| # Manual dispatch for debugging | |
| workflow_dispatch: | |
| permissions: | |
| contents: write # For creating releases | |
| id-token: write # For npm provenance | |
| pull-requests: read # Required by identifiers.yml | |
| env: | |
| # Node 24 is current LTS (Krypton) | |
| NODE_VERSION: '24' | |
| jobs: | |
| identifiers: | |
| # GitHub needs to know where .cicd/workflows/identifiers.yml lives at parse time, | |
| # and submodules aren't included in that context! thus the following does NOT work: | |
| # uses: ./.cicd/workflows/identifiers.yml | |
| # we MUST reference the remote repo directly: | |
| uses: wamp-proto/wamp-cicd/.github/workflows/identifiers.yml@main | |
| # IMPORTANT: we still need .cicd as a Git submodule in the using repo though! | |
| # because e.g. identifiers.yml wants to access scripts/sanitize.sh ! | |
| check-release: | |
| name: Check if release needed | |
| needs: identifiers | |
| runs-on: ubuntu-24.04 | |
| outputs: | |
| release_type: ${{ steps.check.outputs.release_type }} | |
| should_release: ${{ steps.check.outputs.should_release }} | |
| version: ${{ steps.check.outputs.version }} | |
| is_prerelease: ${{ steps.check.outputs.is_prerelease }} | |
| run_id: ${{ steps.check.outputs.run_id }} | |
| steps: | |
| - name: Check trigger conditions | |
| id: check | |
| env: | |
| RELEASE_TYPE: ${{ needs.identifiers.outputs.release_type }} | |
| RELEASE_NAME: ${{ needs.identifiers.outputs.release_name }} | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const { workflow_run } = context.payload; | |
| const releaseType = process.env.RELEASE_TYPE; | |
| const releaseName = process.env.RELEASE_NAME; | |
| console.log('βββββββββββββββββββββββββββββββββββββββββββββββββ'); | |
| console.log('π Checking release conditions'); | |
| console.log('βββββββββββββββββββββββββββββββββββββββββββββββββ'); | |
| console.log(`Release type: ${releaseType}`); | |
| console.log(`Release name: ${releaseName}`); | |
| // For workflow_run trigger | |
| if (workflow_run) { | |
| console.log(`Triggered by: ${workflow_run.name}`); | |
| console.log(`Conclusion: ${workflow_run.conclusion}`); | |
| console.log(`Head branch: ${workflow_run.head_branch}`); | |
| console.log(`Run ID: ${workflow_run.id}`); | |
| // Only release if main workflow succeeded | |
| if (workflow_run.conclusion !== 'success') { | |
| console.log('β Main workflow did not succeed - skipping release'); | |
| core.setOutput('should_release', 'false'); | |
| return; | |
| } | |
| core.setOutput('run_id', workflow_run.id.toString()); | |
| } else { | |
| // Manual dispatch | |
| console.log('Triggered by: manual dispatch'); | |
| core.setOutput('run_id', context.runId.toString()); | |
| } | |
| // Determine release type from identifiers | |
| core.setOutput('release_type', releaseType); | |
| if (releaseType === 'stable') { | |
| // Stable release (v* tag) | |
| const version = releaseName.replace(/^v/, ''); | |
| const isPrerelease = version.includes('-') || version.includes('alpha') || version.includes('beta') || version.includes('rc'); | |
| console.log(`β Stable release: ${version}`); | |
| console.log(` Is prerelease: ${isPrerelease}`); | |
| core.setOutput('should_release', 'true'); | |
| core.setOutput('version', version); | |
| core.setOutput('is_prerelease', isPrerelease ? 'true' : 'false'); | |
| } else if (releaseType === 'development') { | |
| // Development release (master branch) | |
| console.log(`β Development release: ${releaseName}`); | |
| core.setOutput('should_release', 'true'); | |
| core.setOutput('version', releaseName); | |
| core.setOutput('is_prerelease', 'true'); | |
| } else { | |
| console.log(`β Unknown release type: ${releaseType} - skipping`); | |
| core.setOutput('should_release', 'false'); | |
| } | |
| console.log('βββββββββββββββββββββββββββββββββββββββββββββββββ'); | |
| # Development GitHub Release (master branch, no npm publish) | |
| release-development: | |
| name: Development GitHub Release | |
| needs: [identifiers, check-release] | |
| if: | | |
| needs.check-release.outputs.should_release == 'true' && | |
| needs.check-release.outputs.release_type == 'development' | |
| runs-on: ubuntu-24.04 | |
| env: | |
| RELEASE_NAME: ${{ needs.identifiers.outputs.release_name }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Download autobahn build artifacts (verified) | |
| uses: wamp-proto/wamp-cicd/actions/download-artifact-verified@main | |
| with: | |
| name: autobahn-browser-bundle | |
| path: release-assets/autobahn/ | |
| run-id: ${{ needs.check-release.outputs.run_id }} | |
| continue-on-error: true | |
| - name: Download autobahn-xbr build artifacts (verified) | |
| uses: wamp-proto/wamp-cicd/actions/download-artifact-verified@main | |
| with: | |
| name: autobahn-xbr-browser-bundle | |
| path: release-assets/autobahn-xbr/ | |
| run-id: ${{ needs.check-release.outputs.run_id }} | |
| continue-on-error: true | |
| - name: Create Development GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ env.RELEASE_NAME }} | |
| name: ${{ env.RELEASE_NAME }} | |
| prerelease: true | |
| generate_release_notes: true | |
| body: | | |
| ## Development Build | |
| This is an automated development build from the `master` branch. | |
| **β οΈ Not for production use** - This build has not been published to npm. | |
| ### Browser Bundles | |
| Download the browser bundles from the release assets below. | |
| ### For Production | |
| Use stable releases from [npm](https://www.npmjs.com/package/autobahn). | |
| files: | | |
| release-assets/**/* | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| # Stable Release: Publish to npm | |
| publish-npm: | |
| name: Publish to npm | |
| needs: [identifiers, check-release] | |
| if: | | |
| needs.check-release.outputs.should_release == 'true' && | |
| needs.check-release.outputs.release_type == 'stable' | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: v${{ needs.check-release.outputs.version }} | |
| submodules: recursive | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Setup Python 3.11 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Install Just | |
| run: | | |
| curl --proto '=https' --tlsv1.2 -sSf https://just.systems/install.sh | bash -s -- --to ~/bin | |
| echo "$HOME/bin" >> $GITHUB_PATH | |
| - name: Install uv | |
| run: | | |
| curl -LsSf https://astral.sh/uv/install.sh | sh | |
| echo "$HOME/.local/bin" >> $GITHUB_PATH | |
| - name: Build packages | |
| run: | | |
| just build-autobahn | |
| just build-xbr | |
| - name: Verify package versions match tag | |
| run: | | |
| VERSION="${{ needs.check-release.outputs.version }}" | |
| AB_VERSION=$(node -p "require('./packages/autobahn/package.json').version") | |
| XBR_VERSION=$(node -p "require('./packages/autobahn-xbr/package.json').version") | |
| echo "Tag version: $VERSION" | |
| echo "autobahn version: $AB_VERSION" | |
| echo "autobahn-xbr version: $XBR_VERSION" | |
| if [ "$AB_VERSION" != "$VERSION" ]; then | |
| echo "ERROR: autobahn version ($AB_VERSION) does not match tag ($VERSION)" | |
| exit 1 | |
| fi | |
| if [ "$XBR_VERSION" != "$VERSION" ]; then | |
| echo "ERROR: autobahn-xbr version ($XBR_VERSION) does not match tag ($VERSION)" | |
| exit 1 | |
| fi | |
| echo "Version check passed!" | |
| - name: Publish autobahn to npm | |
| run: | | |
| cd packages/autobahn | |
| npm publish --provenance --access public | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - name: Publish autobahn-xbr to npm | |
| run: | | |
| cd packages/autobahn-xbr | |
| # Update autobahn dependency from local to npm version before publishing | |
| npm pkg set dependencies.autobahn="^${{ needs.check-release.outputs.version }}" | |
| npm publish --provenance --access public | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| # Stable Release: Create GitHub Release (after npm publish) | |
| release-stable: | |
| name: Stable GitHub Release | |
| needs: [identifiers, check-release, publish-npm] | |
| if: | | |
| needs.check-release.outputs.should_release == 'true' && | |
| needs.check-release.outputs.release_type == 'stable' | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: v${{ needs.check-release.outputs.version }} | |
| submodules: recursive | |
| - name: Download autobahn build artifacts (verified) | |
| uses: wamp-proto/wamp-cicd/actions/download-artifact-verified@main | |
| with: | |
| name: autobahn-browser-bundle | |
| path: release-assets/autobahn/ | |
| run-id: ${{ needs.check-release.outputs.run_id }} | |
| continue-on-error: true | |
| - name: Download autobahn-xbr build artifacts (verified) | |
| uses: wamp-proto/wamp-cicd/actions/download-artifact-verified@main | |
| with: | |
| name: autobahn-xbr-browser-bundle | |
| path: release-assets/autobahn-xbr/ | |
| run-id: ${{ needs.check-release.outputs.run_id }} | |
| continue-on-error: true | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: v${{ needs.check-release.outputs.version }} | |
| name: v${{ needs.check-release.outputs.version }} | |
| prerelease: ${{ needs.check-release.outputs.is_prerelease == 'true' }} | |
| generate_release_notes: true | |
| files: | | |
| release-assets/**/* | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |