Merge pull request #2 from LinkForty/feat/app-token #2
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 | |
| on: | |
| push: | |
| branches: | |
| - main | |
| # Only allow one release at a time | |
| concurrency: | |
| group: release | |
| cancel-in-progress: false | |
| jobs: | |
| release: | |
| name: Release to NPM & GitHub | |
| runs-on: ubuntu-latest | |
| if: github.repository == 'LinkForty/mobile-sdk-react-native' && github.ref == 'refs/heads/main' | |
| timeout-minutes: 20 | |
| environment: npm-production | |
| permissions: | |
| contents: write # To create releases and tags | |
| issues: write # To comment on released issues | |
| pull-requests: write # To comment on released PRs | |
| id-token: write # For NPM OIDC trusted publishing | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Fetch all history for semantic-release | |
| persist-credentials: false | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22' | |
| cache: 'npm' | |
| - name: Update npm to latest | |
| run: npm install -g npm@latest | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build package | |
| run: npm run build | |
| - name: Release | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: npx semantic-release | |
| notify-failure: | |
| name: Notify Release Failure | |
| runs-on: ubuntu-latest | |
| needs: release | |
| if: failure() && github.repository == 'LinkForty/mobile-sdk-react-native' | |
| permissions: | |
| issues: write | |
| steps: | |
| - name: Create issue on failure | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const title = `Release failed on ${new Date().toISOString()}`; | |
| const body = `The release workflow failed. Please check the [workflow run](${context.payload.repository.html_url}/actions/runs/${context.runId}).`; | |
| const issues = await github.rest.issues.listForRepo({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| state: 'open', | |
| labels: 'release-failure' | |
| }); | |
| if (issues.data.length === 0) { | |
| await github.rest.issues.create({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| title: title, | |
| body: body, | |
| labels: ['release-failure', 'automated'] | |
| }); | |
| } |