|
| 1 | +name: Release SwaggerUI |
| 2 | +on: |
| 3 | + workflow_dispatch: |
| 4 | + branches: |
| 5 | + - master |
| 6 | + |
| 7 | +jobs: |
| 8 | + release: |
| 9 | + name: Release swagger-ui npm package |
| 10 | + runs-on: ubuntu-latest |
| 11 | + steps: |
| 12 | + - name: Checkout |
| 13 | + uses: actions/checkout@v4 |
| 14 | + with: |
| 15 | + fetch-depth: 0 |
| 16 | + persist-credentials: false |
| 17 | + ref: master |
| 18 | + |
| 19 | + - name: Setup Node.js |
| 20 | + uses: actions/setup-node@v4 |
| 21 | + with: |
| 22 | + node-version: 22 |
| 23 | + cache: npm |
| 24 | + cache-dependency-path: package-lock.json |
| 25 | + |
| 26 | + - name: Determine the next release version |
| 27 | + uses: cycjimmy/semantic-release-action@v4 |
| 28 | + with: |
| 29 | + dry_run: true |
| 30 | + extra_plugins: | |
| 31 | + @semantic-release/git |
| 32 | + @semantic-release/exec |
| 33 | + env: |
| 34 | + GITHUB_TOKEN: ${{ secrets.SWAGGER_BOT_GITHUB_TOKEN }} |
| 35 | + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 36 | + |
| 37 | + - name: Nothing to release |
| 38 | + if: ${{ env.NEXT_RELEASE_VERSION == '' }} |
| 39 | + uses: actions/github-script@v7 |
| 40 | + with: |
| 41 | + script: | |
| 42 | + core.setFailed('Nothing to release') |
| 43 | +
|
| 44 | + - name: Install dependencies |
| 45 | + run: npm ci |
| 46 | + |
| 47 | + - name: Prepare for the Release |
| 48 | + env: |
| 49 | + REACT_APP_VERSION: ${{ env.NEXT_RELEASE_VERSION }} |
| 50 | + run: | |
| 51 | + npm run test |
| 52 | + npm run build |
| 53 | +
|
| 54 | + - name: Semantic Release |
| 55 | + id: semantic |
| 56 | + uses: cycjimmy/semantic-release-action@v4 |
| 57 | + with: |
| 58 | + dry_run: false |
| 59 | + extra_plugins: | |
| 60 | + @semantic-release/git |
| 61 | + env: |
| 62 | + GITHUB_TOKEN: ${{ secrets.SWAGGER_BOT_GITHUB_TOKEN }} |
| 63 | + NPM_TOKEN: ${{ secrets.SWAGGER_BOT_GITHUB_TOKEN }} |
| 64 | + |
| 65 | + - name: Release failed |
| 66 | + if: steps.semantic.outputs.new_release_published == 'false' |
| 67 | + uses: actions/github-script@v7 |
| 68 | + with: |
| 69 | + script: | |
| 70 | + core.setFailed('Release failed') |
| 71 | +
|
| 72 | + - name: Release published |
| 73 | + run: | |
| 74 | + echo ${{ steps.semantic.outputs.new_release_version }} |
| 75 | + echo ${{ steps.semantic.outputs.new_release_major_version }} |
| 76 | + echo ${{ steps.semantic.outputs.new_release_minor_version }} |
| 77 | + echo ${{ steps.semantic.outputs.new_release_patch_version }} |
| 78 | +
|
| 79 | + - name: Upload build artifacts |
| 80 | + uses: actions/upload-artifact@v4 |
| 81 | + with: |
| 82 | + name: dist |
| 83 | + path: ./dist |
| 84 | + |
| 85 | + |
| 86 | + - name: Prepare released version for uploading |
| 87 | + shell: bash |
| 88 | + run: | |
| 89 | + echo ${{ steps.semantic.outputs.new_release_version }} > released-version.txt |
| 90 | + - name: Upload released version |
| 91 | + uses: actions/upload-artifact@v4 |
| 92 | + with: |
| 93 | + name: released-version |
| 94 | + path: ./released-version.txt |
| 95 | + retention-days: 1 |
0 commit comments