๐Ÿ“ฆ juspay / hyper-sdk-react

๐Ÿ“„ release.yml ยท 102 lines
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102name: Releases
on:
  pull_request_target:
    branches:
      - main
    types:
      - closed

jobs:
  merged-pr:
    if: github.event.pull_request.merged == true && !contains(github.event.pull_request.title, '[skip ci]')
    runs-on: ubuntu-latest
    permissions:
      id-token: write
      contents: read
    steps:

      - name: Generate GitHub app token
        id: generate_app_token
        uses: actions/create-github-app-token@v1
        with:
          app-id: ${{ vars.HYPER_SDK_APP_ID }}
          private-key: ${{ secrets.HYPER_SDK_APP_PRIVATE_KEY }}

      - name: Checkout code
        uses: actions/checkout@v4
        with:
          repository: ${{ github.event.pull_request.head.repo.full_name }}
          token: ${{ steps.generate_app_token.outputs.token }}
          fetch-depth: ${{ github.event.pull_request.commits }}

      - name: Set up Node.js
        uses: actions/setup-node@v3
        with:
          node-version: 24
          registry-url: "https://registry.npmjs.org"

      - name: Install dependencies
        run: yarn install --frozen-lockfile

      - name: Determine release type
        id: determine-release
        run: |
          shopt -s nocasematch

          PR_TITLE='${{ github.event.pull_request.title }}'

          if [[ "$PR_TITLE" =~ (\[breaking\]|\[major\]) ]]; then
            echo "release_type=major" >> $GITHUB_OUTPUT
          elif [[ "$PR_TITLE" =~ \[minor\] ]]; then
            echo "release_type=minor" >> $GITHUB_OUTPUT
          else
            echo "release_type=patch" >> $GITHUB_OUTPUT
          fi

          shopt -u nocasematch
        shell: bash

      - name: Conventional Changelog Action
        id: changelog
        uses: TriPSs/conventional-changelog-action@v5.1.0
        with:
          github-token: ${{ steps.generate_app_token.outputs.token }}
          release-count: 0
          skip-version-file: "true"
          skip-commit: "true"
          git-push: "false"
          skip-tag: "true"
          skip-bump: "true"
          output-file: "false"

      - name: Stash changes
        run: git reset --hard

      - name: git config
        run: |
          git config --local user.name 'hyper-sdk-app[bot]'
          git config --local user.email '163947841+hyper-sdk-app[bot]@users.noreply.github.com'

      - name: Run standard version
        id: standard-version
        run: |
          npx standard-version --release-as ${{ steps.determine-release.outputs.release_type }}
          echo "tag_name=$(git describe --abbrev=0 --tags)" >>$GITHUB_OUTPUT

      - name: Push tags and changelog
        run: git push --follow-tags origin main
        env:
          GH_TOKEN: ${{ steps.generate_app_token.outputs.token }}

      - name: create release
        uses: actions/create-release@v1
        env:
          GITHUB_TOKEN: ${{ steps.generate_app_token.outputs.token }}
        with:
          tag_name: "${{ steps.standard-version.outputs.tag_name }}"
          release_name: "${{ steps.standard-version.outputs.tag_name }}"
          body: "${{ steps.changelog.outputs.clean_changelog }}"

      - name: Publish package on NPM ๐Ÿ“ฆ
        run: npm publish