|
| 1 | +name: Release Full(OTP) |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + tag: |
| 7 | + type: choice |
| 8 | + description: "Release Npm Tag" |
| 9 | + required: true |
| 10 | + default: "latest" |
| 11 | + options: |
| 12 | + - canary |
| 13 | + - nightly |
| 14 | + - latest |
| 15 | + - beta |
| 16 | + - alpha |
| 17 | + test: |
| 18 | + type: boolean |
| 19 | + description: "Run tests before release" |
| 20 | + required: true |
| 21 | + default: true |
| 22 | + dry_run: |
| 23 | + type: boolean |
| 24 | + description: "DryRun release" |
| 25 | + required: true |
| 26 | + default: false |
| 27 | + push_tags: |
| 28 | + type: boolean |
| 29 | + description: "push tags to github" |
| 30 | + required: true |
| 31 | + default: true |
| 32 | + |
| 33 | +permissions: |
| 34 | + # To publish packages with provenance |
| 35 | + id-token: write |
| 36 | + # Allow commenting on issues for `reusable-build.yml` |
| 37 | + issues: write |
| 38 | + |
| 39 | +jobs: |
| 40 | + get-runner-labels: |
| 41 | + name: Get Runner Labels |
| 42 | + uses: ./.github/workflows/get-runner-labels.yml |
| 43 | + with: |
| 44 | + force-use-github-runner: true |
| 45 | + |
| 46 | + build: |
| 47 | + needs: [ get-runner-labels ] |
| 48 | + strategy: |
| 49 | + fail-fast: false # Build and test everything so we can look at all the errors |
| 50 | + matrix: |
| 51 | + array: |
| 52 | + - target: x86_64-unknown-linux-gnu |
| 53 | + runner: ${{ needs.get-runner-labels.outputs.LINUX_RUNNER_LABELS }} |
| 54 | + - target: aarch64-unknown-linux-gnu |
| 55 | + runner: ${{ needs.get-runner-labels.outputs.LINUX_RUNNER_LABELS }} |
| 56 | + - target: x86_64-unknown-linux-musl |
| 57 | + runner: ${{ needs.get-runner-labels.outputs.LINUX_RUNNER_LABELS }} |
| 58 | + - target: aarch64-unknown-linux-musl |
| 59 | + runner: ${{ needs.get-runner-labels.outputs.LINUX_RUNNER_LABELS }} |
| 60 | + - target: i686-pc-windows-msvc |
| 61 | + runner: ${{ needs.get-runner-labels.outputs.WINDOWS_RUNNER_LABELS }} |
| 62 | + - target: x86_64-pc-windows-msvc |
| 63 | + runner: ${{ needs.get-runner-labels.outputs.WINDOWS_RUNNER_LABELS }} |
| 64 | + - target: aarch64-pc-windows-msvc |
| 65 | + runner: ${{ needs.get-runner-labels.outputs.WINDOWS_RUNNER_LABELS }} |
| 66 | + - target: x86_64-apple-darwin |
| 67 | + runner: ${{ needs.get-runner-labels.outputs.MACOS_RUNNER_LABELS }} |
| 68 | + - target: aarch64-apple-darwin |
| 69 | + runner: ${{ needs.get-runner-labels.outputs.MACOS_RUNNER_LABELS }} |
| 70 | + uses: ./.github/workflows/reusable-build.yml |
| 71 | + with: |
| 72 | + target: ${{ matrix.array.target }} |
| 73 | + runner: ${{ matrix.array.runner }} |
| 74 | + test: ${{ inputs.test }} |
| 75 | + profile: "release" |
| 76 | + |
| 77 | + release: |
| 78 | + name: Release |
| 79 | + environment: npm |
| 80 | + permissions: |
| 81 | + contents: write |
| 82 | + # To publish packages with provenance |
| 83 | + id-token: write |
| 84 | + runs-on: ubuntu-latest |
| 85 | + needs: build |
| 86 | + if: ${{ github.event_name == 'workflow_dispatch' }} |
| 87 | + steps: |
| 88 | + - name: Checkout Repo |
| 89 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 |
| 90 | + with: |
| 91 | + # This makes Actions fetch only one branch to release |
| 92 | + fetch-depth: 1 |
| 93 | + |
| 94 | + - name: Pnpm Cache |
| 95 | + uses: ./.github/actions/pnpm-cache |
| 96 | + |
| 97 | + - name: Download artifacts |
| 98 | + uses: actions/download-artifact@v4.1.7 |
| 99 | + with: |
| 100 | + path: artifacts |
| 101 | + |
| 102 | + - name: Build node packages |
| 103 | + run: pnpm run build:js |
| 104 | + |
| 105 | + - name: Move artifacts |
| 106 | + run: node scripts/build-npm.cjs |
| 107 | + |
| 108 | + - name: Show binding packages |
| 109 | + run: ls -R npm |
| 110 | + |
| 111 | + - name: Link optional dependencies |
| 112 | + run: pnpm install --no-frozen-lockfile |
| 113 | + |
| 114 | + - name: Obtain OIDC token |
| 115 | + id: oidc |
| 116 | + run: | |
| 117 | + token=$(curl --fail -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \ |
| 118 | + "$ACTIONS_ID_TOKEN_REQUEST_URL&audience=cfa.rspack.dev" | jq -r '.value') |
| 119 | + echo "::add-mask::${token}" |
| 120 | + echo "token=${token}" >> $GITHUB_OUTPUT |
| 121 | + shell: bash |
| 122 | + |
| 123 | + - name: Obtain GitHub credentials |
| 124 | + id: github_creds |
| 125 | + run: | |
| 126 | + token=$(curl --fail "https://cfa.rspack.dev/api/request/${{ secrets.CFA_PROJECT_ID }}/github/credentials" \ |
| 127 | + -X POST \ |
| 128 | + -H "Content-Type: application/json" \ |
| 129 | + -H "Authorization: bearer ${{ secrets.CFA_SECRET }}" \ |
| 130 | + --data "{\"token\":\"${{ steps.oidc.outputs.token }}\"}" | jq -r '.GITHUB_TOKEN') |
| 131 | + echo "::add-mask::${token}" |
| 132 | + echo "token=${token}" >> $GITHUB_OUTPUT |
| 133 | + shell: bash |
| 134 | + |
| 135 | + - name: Release Full |
| 136 | + run: | |
| 137 | + ./x publish stable --otp --tag ${{inputs.tag}} ${{inputs.dry_run && '--dry-run' || '--no-dry-run'}} ${{inputs.push_tags && '--push-tags' || '--no-push-tags'}} |
| 138 | + env: |
| 139 | + NPM_TOKEN: ${{ secrets.OTP_NPM_TOKEN }} |
| 140 | + REPOSITORY: ${{ github.repository }} |
| 141 | + REF: ${{ github.ref }} |
| 142 | + ONLY_RELEASE_TAG: true |
| 143 | + # CFA required environment variables |
| 144 | + CFA_HOST: https://cfa.rspack.dev |
| 145 | + GITHUB_TOKEN: ${{ steps.github_creds.outputs.token }} |
| 146 | + GITHUB_OIDC_TOKEN: ${{ steps.oidc.outputs.token }} |
| 147 | + CFA_PROJECT_ID: ${{ secrets.CFA_PROJECT_ID }} |
| 148 | + CFA_SECRET: ${{ secrets.CFA_SECRET }} |
0 commit comments