diff --git a/.github/workflows/alpha.yml b/.github/workflows/alpha.yml new file mode 100644 index 0000000000..3affea3ac9 --- /dev/null +++ b/.github/workflows/alpha.yml @@ -0,0 +1,55 @@ +name: Release (Alpha) +on: + workflow_dispatch: + inputs: + preid: + description: 'Pre-release identifier (e.g., alpha.1)' + required: true + type: string + dry_run: + description: 'Dry run (no actual publish)' + type: boolean + default: false + +jobs: + alpha: + name: Release alpha + runs-on: ubuntu-latest + # Require explicit environment approval + environment: + name: alpha-release + url: https://www.npmjs.com/package/@coinbase/onchainkit + permissions: + contents: read + id-token: write + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: 'Setup' + uses: ./.github/actions/setup + + - name: Set version + run: | + BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/} | tr -cs '[:alnum:]-' '-' | tr '[:upper:]' '[:lower:]') + npm --no-git-tag-version version $(npm pkg get version | sed 's/"//g')-${BRANCH_NAME}.$(echo ${{ github.event.inputs.preid }}) + + - name: Build + shell: bash + run: yarn build + + - name: Test package + if: ${{ inputs.dry_run }} + run: npm publish --dry-run --tag alpha + + - name: Set deployment token + if: ${{ !inputs.dry_run }} + run: npm config set '//registry.npmjs.org/:_authToken' "${{ secrets.NPM_TOKEN }}" + + - name: Publish to npm + if: ${{ !inputs.dry_run }} + run: npm publish --tag alpha + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}