Release typescript #56
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 typescript | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| project: | |
| type: choice | |
| description: Library to release | |
| required: true | |
| options: | |
| - aqua | |
| - sdk-core | |
| - swap-vm | |
| bump: | |
| type: choice | |
| description: Semver bump or custom | |
| required: true | |
| options: | |
| - patch | |
| - minor | |
| - major | |
| - prerelease | |
| preid: | |
| type: string | |
| description: Prerelease identifier (used when bump = prerelease) | |
| required: false | |
| default: rc | |
| dry_run: | |
| type: boolean | |
| description: Dry Run | |
| required: false | |
| default: false | |
| permissions: | |
| contents: write | |
| packages: write | |
| actions: write | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| project: ${{ steps.pkg.outputs.project }} | |
| sdk_path: ${{ steps.pkg.outputs.sdk_path }} | |
| package_name: ${{ steps.pkg.outputs.package_name }} | |
| pkg_version: ${{ steps.pkg.outputs.pkg_version }} | |
| tag: ${{ steps.pkg.outputs.tag }} | |
| steps: | |
| - name: Checkout master | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| fetch-tags: true | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v4 | |
| - name: Setup Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22.14.0 | |
| cache: pnpm | |
| registry-url: https://registry.npmjs.org | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Configure git | |
| run: | | |
| git config --global user.email "ci_cd_bot@1inch.io" | |
| git config --global user.name "CI/CD Bot" | |
| env: | |
| GITHUB_TOKEN: ${{ github.token }} | |
| - name: Run Nx release | |
| id: version | |
| env: | |
| GITHUB_TOKEN: ${{ github.token }} | |
| run: | | |
| SPECIFIER="${{ inputs.bump }}" | |
| PREID_FLAG="" | |
| if [ "${{ inputs.bump }}" = "prerelease" ] && [ -n "${{ inputs.preid }}" ]; then | |
| PREID_FLAG="--preid ${{ inputs.preid }}" | |
| fi | |
| DRY_RUN_FLAG="" | |
| if [ "${{ inputs.dry_run }}" = "true" ]; then | |
| DRY_RUN_FLAG="--dry-run" | |
| fi | |
| npx nx release "$SPECIFIER" \ | |
| --projects="${{ inputs.project }}" \ | |
| $PREID_FLAG \ | |
| $DRY_RUN_FLAG \ | |
| --skip-publish \ | |
| --verbose | |
| - name: Resolve package info | |
| id: pkg | |
| run: | | |
| SDK_PATH="typescript/${{ inputs.project }}" | |
| PKG_NAME=$(node -p "require('./$SDK_PATH/package.json').name") | |
| PKG_VERSION=$(node -p "require('./$SDK_PATH/package.json').version") | |
| TAG="${{ inputs.project }}/v${PKG_VERSION}" | |
| echo "project=${{ inputs.project }}" >> "$GITHUB_OUTPUT" | |
| echo "sdk_path=$SDK_PATH" >> "$GITHUB_OUTPUT" | |
| echo "package_name=$PKG_NAME" >> "$GITHUB_OUTPUT" | |
| echo "pkg_version=$PKG_VERSION" >> "$GITHUB_OUTPUT" | |
| echo "tag=$TAG" >> "$GITHUB_OUTPUT" | |
| - name: Show updated version | |
| run: | | |
| if [ "${{ inputs.dry_run }}" = "true" ]; then | |
| echo "(dry-run: version on disk is unchanged)" | |
| fi | |
| echo "Version = ${{ steps.pkg.outputs.pkg_version }}" | |
| publish-npmjs: | |
| runs-on: ubuntu-latest | |
| needs: release | |
| if: ${{ github.event.inputs.dry_run != 'true' }} | |
| permissions: | |
| contents: read | |
| packages: write | |
| id-token: write | |
| steps: | |
| - name: Checkout tag | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ needs.release.outputs.tag }} | |
| fetch-depth: 0 | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v4 | |
| - name: Setup Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22.14.0 | |
| cache: pnpm | |
| registry-url: https://registry.npmjs.org | |
| always-auth: true | |
| # npm 11+ supports OIDC provenance; pnpm publish delegates attestation to npm for npmjs | |
| - name: Install npm@11 | |
| run: npm install -g npm@11 | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Build package (pnpm) | |
| run: pnpm --filter "${{ needs.release.outputs.package_name }}" build | |
| - name: Publish to npmjs | |
| run: | | |
| TAG_ARG="" | |
| if [ "${{ github.event.inputs.bump }}" = "prerelease" ]; then | |
| TAG_ARG="--tag next" | |
| fi | |
| pnpm --filter "${{ needs.release.outputs.package_name }}" publish --access public --provenance --no-git-checks $TAG_ARG | |
| publish-github-packages: | |
| runs-on: ubuntu-latest | |
| needs: release | |
| if: ${{ github.event.inputs.dry_run != 'true' }} | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout tag | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ needs.release.outputs.tag }} | |
| fetch-depth: 0 | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v4 | |
| - name: Setup Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22.14.0 | |
| cache: pnpm | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Build package (pnpm) | |
| run: pnpm --filter "${{ needs.release.outputs.package_name }}" build | |
| - name: Publish to GitHub Packages | |
| env: | |
| NODE_AUTH_TOKEN: ${{ github.token }} | |
| run: | | |
| npm config set @1inch:registry https://npm.pkg.github.com | |
| npm config set //npm.pkg.github.com/:_authToken "${NODE_AUTH_TOKEN}" | |
| pnpm --filter "${{ needs.release.outputs.package_name }}" publish --access public --no-git-checks |