|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: read |
| 10 | + |
| 11 | +concurrency: ${{ github.workflow }}-${{ github.ref }} |
| 12 | + |
| 13 | +jobs: |
| 14 | + release-stable: |
| 15 | + runs-on: ubuntu-24.04 |
| 16 | + name: Release Stable |
| 17 | + env: |
| 18 | + NPM_CONFIG_PROVENANCE: "true" |
| 19 | + permissions: |
| 20 | + contents: write |
| 21 | + id-token: write # Needed for npm trusted publishing |
| 22 | + pull-requests: write |
| 23 | + outputs: |
| 24 | + published: ${{ steps.changesets.outputs.published }} |
| 25 | + steps: |
| 26 | + - name: Checkout Repo |
| 27 | + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 28 | + |
| 29 | + - uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0 |
| 30 | + |
| 31 | + - name: Setup NodeJS |
| 32 | + uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 |
| 33 | + with: |
| 34 | + node-version: 24 |
| 35 | + cache: "pnpm" |
| 36 | + |
| 37 | + - name: Install Dependencies |
| 38 | + run: pnpm install --frozen-lockfile |
| 39 | + |
| 40 | + - name: Configure Git |
| 41 | + run: | |
| 42 | + git config --global user.name "github-actions[bot]" |
| 43 | + git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 44 | +
|
| 45 | + - name: Create Release Pull Request or Publish to npm |
| 46 | + id: changesets |
| 47 | + uses: changesets/action@ae32849d5ba541f9ae29e40e22a623bc13562f51 # v2.1.2 |
| 48 | + with: |
| 49 | + pr-title: "chore(release): new version" |
| 50 | + commit-message: "chore(release): new version" |
| 51 | + publish-script: pnpm release |
| 52 | + version-script: pnpm changeset-version |
| 53 | + push-with-git-cli: true |
| 54 | + env: |
| 55 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 56 | + |
| 57 | + - name: Get current package version |
| 58 | + id: get_version |
| 59 | + run: echo "current_package_version=$(node -p "require('./pex/package.json').version")" >> $GITHUB_OUTPUT |
| 60 | + |
| 61 | + - name: Create Github Release |
| 62 | + if: "startsWith(github.event.head_commit.message, 'chore(release): new version')" |
| 63 | + uses: softprops/action-gh-release@efb35369e0ad2afab669f228072c1b0d510eae64 # v3.0.3 |
| 64 | + with: |
| 65 | + tag_name: v${{ steps.get_version.outputs.current_package_version }} |
| 66 | + |
| 67 | + release-unstable: |
| 68 | + runs-on: ubuntu-24.04 |
| 69 | + name: Release Unstable |
| 70 | + needs: release-stable |
| 71 | + if: always() && github.event_name == 'push' && needs.release-stable.outputs.published == 'false' |
| 72 | + env: |
| 73 | + NPM_CONFIG_PROVENANCE: "true" |
| 74 | + permissions: |
| 75 | + contents: write |
| 76 | + id-token: write # Needed for npm trusted publishing |
| 77 | + steps: |
| 78 | + - name: Checkout Repo |
| 79 | + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 80 | + |
| 81 | + - uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0 |
| 82 | + |
| 83 | + - name: Setup NodeJS |
| 84 | + uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 |
| 85 | + with: |
| 86 | + node-version: 24 |
| 87 | + cache: "pnpm" |
| 88 | + |
| 89 | + - name: Install Dependencies |
| 90 | + run: pnpm install --frozen-lockfile |
| 91 | + |
| 92 | + - name: Create unstable release |
| 93 | + env: |
| 94 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 95 | + run: | |
| 96 | + # ensure there's always a patch release created |
| 97 | + cat << 'EOF' > .changeset/snapshot-template-changeset.md |
| 98 | + --- |
| 99 | + '@owf/pex': patch |
| 100 | + --- |
| 101 | +
|
| 102 | + snapshot release |
| 103 | + EOF |
| 104 | +
|
| 105 | + pnpm changeset version --snapshot alpha |
| 106 | + pnpm style:fix |
| 107 | + pnpm types:check |
| 108 | + pnpm build |
| 109 | + pnpm esm:check |
| 110 | + pnpm changeset publish --tag alpha |
| 111 | +
|
| 112 | + CURRENT_PACKAGE_VERSION=$(node -p "require('./pex/package.json').version") |
| 113 | + git config --global user.name "github-actions[bot]" |
| 114 | + git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 115 | + git tag v$CURRENT_PACKAGE_VERSION |
| 116 | + git push origin v$CURRENT_PACKAGE_VERSION --no-verify |
0 commit comments