Merge pull request #1269 from Shopify/changeset-release/main #506
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 Workflow | |
| on: | |
| push: | |
| branches: | |
| - main | |
| concurrency: ${{ github.workflow }}-${{ github.ref }} | |
| env: | |
| VSCE_PAT: ${{ secrets.VSCE_PAT }} | |
| OVSX_PAT: ${{ secrets.OPENVSX_TOKEN }} | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| npm_config_registry: "https://registry.npmjs.org" | |
| jobs: | |
| publish-packages: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| id-token: write | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| submodules: true | |
| fetch-depth: 0 | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9 | |
| with: | |
| run_install: false | |
| - name: Setup Node.js | |
| uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 | |
| with: | |
| node-version: 24 | |
| registry-url: "https://registry.npmjs.org" | |
| cache: "pnpm" | |
| cache-dependency-path: "pnpm-lock.yaml" | |
| - name: Install the packages | |
| run: pnpm install --frozen-lockfile | |
| - name: Build the code | |
| run: pnpm build | |
| env: | |
| NODE_ENV: production | |
| - name: Grab date as YYYY-MM-DD | |
| id: date | |
| run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT | |
| - name: Query VS Code Marketplace version | |
| id: marketplace-version | |
| run: echo "version=$(pnpm --dir packages/vscode-extension exec vsce show --json Shopify.theme-check-vscode | jq -r .versions[0].version)" >> $GITHUB_OUTPUT | |
| - name: Query VS Code Package version (Before running changeset version) | |
| id: package-version | |
| run: echo "version=$(jq -r .version packages/vscode-extension/package.json)" >> $GITHUB_OUTPUT | |
| - name: Test OIDC Token | |
| run: | | |
| TOKEN=$(curl -s -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \ | |
| "$ACTIONS_ID_TOKEN_REQUEST_URL&audience=npm" | jq -r '.value') | |
| [ -n "$TOKEN" ] && echo "✅ OIDC working" || exit 1 | |
| - name: Create Release Pull Request or Publish to npm | |
| id: changesets | |
| uses: changesets/action@a45c4d594aa4e2c509dc14a9f2b3b67ba3780d0d # v1.9.0 | |
| with: | |
| # Put date in the title and commit message | |
| title: "Theme Tools Release — ${{ steps.date.outputs.date }}" | |
| commit: "Theme Tools Release — ${{ steps.date.outputs.date }}" | |
| # When there are no changesets, this gets called | |
| publish: pnpm changeset publish | |
| # When there are changesets, this gets called and then a PR is opened/updated | |
| version: pnpm release | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| NPM_CONFIG_PROVENANCE: true | |
| - name: VS Code Marketplace publish | |
| if: steps.changesets.outputs.hasChangesets == 'false' && steps.marketplace-version.outputs.version != steps.package-version.outputs.version | |
| run: pnpm publish:vsce | |
| - name: Open VSX Registry publish | |
| if: steps.changesets.outputs.hasChangesets == 'false' && steps.marketplace-version.outputs.version != steps.package-version.outputs.version | |
| run: pnpm publish:ovsx |