|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + |
| 8 | +concurrency: ${{ github.workflow }}-${{ github.ref }} |
| 9 | + |
| 10 | +jobs: |
| 11 | + release-stable: |
| 12 | + runs-on: ubuntu-latest |
| 13 | + name: Release Stable |
| 14 | + outputs: |
| 15 | + published: ${{ steps.changesets.outputs.published }} |
| 16 | + steps: |
| 17 | + - name: Checkout Repo |
| 18 | + uses: actions/checkout@v4 |
| 19 | + |
| 20 | + - uses: pnpm/action-setup@v4 |
| 21 | + - name: Setup NodeJS |
| 22 | + uses: actions/setup-node@v4 |
| 23 | + with: |
| 24 | + node-version: 20 |
| 25 | + cache: "pnpm" |
| 26 | + |
| 27 | + - name: Install Dependencies |
| 28 | + run: pnpm install --frozen-lockfile |
| 29 | + |
| 30 | + - name: Create Release Pull Request or Publish to npm |
| 31 | + id: changesets |
| 32 | + uses: changesets/action@v1 |
| 33 | + with: |
| 34 | + title: "chore(release): new version" |
| 35 | + commit: "chore(release): new version" |
| 36 | + publish: pnpm release |
| 37 | + version: pnpm changeset-version |
| 38 | + env: |
| 39 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 40 | + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 41 | + |
| 42 | + - name: Get current package version |
| 43 | + id: get_version |
| 44 | + run: echo "CURRENT_PACKAGE_VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV |
| 45 | + |
| 46 | + - name: Create Github Release |
| 47 | + if: steps.changesets.outputs.published == 'true' |
| 48 | + uses: softprops/action-gh-release@v2 |
| 49 | + with: |
| 50 | + tag_name: v${{ env.CURRENT_PACKAGE_VERSION }} |
| 51 | + |
| 52 | + release-unstable: |
| 53 | + runs-on: ubuntu-latest |
| 54 | + name: Release Unstable |
| 55 | + needs: release-stable |
| 56 | + if: always() && github.event_name == 'push' && needs.release-stable.outputs.published == 'false' |
| 57 | + steps: |
| 58 | + - name: Checkout Repo |
| 59 | + uses: actions/checkout@v4 |
| 60 | + |
| 61 | + - uses: pnpm/action-setup@v4 |
| 62 | + - name: Setup NodeJS |
| 63 | + uses: actions/setup-node@v4 |
| 64 | + with: |
| 65 | + node-version: 20 |
| 66 | + cache: "pnpm" |
| 67 | + |
| 68 | + - name: Install Dependencies |
| 69 | + run: pnpm install --frozen-lockfile |
| 70 | + |
| 71 | + - name: Creating .npmrc |
| 72 | + run: | |
| 73 | + cat << EOF > ".npmrc" |
| 74 | + //registry.npmjs.org/:_authToken=$NPM_TOKEN |
| 75 | + EOF |
| 76 | + env: |
| 77 | + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 78 | + |
| 79 | + - name: Create unstable release |
| 80 | + env: |
| 81 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 82 | + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 83 | + run: | |
| 84 | + # this ensures there's always a patch release created |
| 85 | + cat << 'EOF' > .changeset/snapshot-template-changeset.md |
| 86 | + --- |
| 87 | + '@animo-id/eudi-wallet-functionality': patch |
| 88 | + --- |
| 89 | +
|
| 90 | + snapshot release |
| 91 | + EOF |
| 92 | +
|
| 93 | + pnpm changeset version --snapshot alpha |
| 94 | + pnpm style:fix |
| 95 | + pnpm build |
| 96 | + pnpm changeset publish --tag alpha |
| 97 | +
|
| 98 | + CURRENT_PACKAGE_VERSION=$(node -p "require('./package.json').version") |
| 99 | + git config --global user.name "github-actions[bot]" |
| 100 | + git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 101 | + git tag v$CURRENT_PACKAGE_VERSION |
| 102 | + git push origin v$CURRENT_PACKAGE_VERSION --no-verify |
0 commit comments