|
| 1 | +name: 🔧 Release (Manual) |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + release-as: |
| 7 | + description: 'Release Version' |
| 8 | + required: true |
| 9 | + release-type: |
| 10 | + description: 'Release Type' |
| 11 | + type: choice |
| 12 | + required: true |
| 13 | + default: 'edge' |
| 14 | + options: |
| 15 | + - edge |
| 16 | + - latest |
| 17 | + |
| 18 | +jobs: |
| 19 | + release: |
| 20 | + runs-on: ubuntu-latest |
| 21 | + |
| 22 | + steps: |
| 23 | + - uses: actions/checkout@v4 |
| 24 | + with: |
| 25 | + ref: ${{ github.event.inputs.release-type == 'latest' && 'master' || 'edge'}} |
| 26 | + |
| 27 | + - run: npm ci |
| 28 | + |
| 29 | + - name: Release PR |
| 30 | + uses: google-github-actions/release-please-action@v3 |
| 31 | + id: release |
| 32 | + with: |
| 33 | + token: ${{ secrets.BOT_TOKEN }} |
| 34 | + release-type: node |
| 35 | + release-as: ${{ github.event.inputs.release-as }} |
| 36 | + prerelease: ${{ github.event.inputs.release-type == 'edge'}} |
| 37 | + default-branch: ${{ github.event.inputs.release-type == 'latest' && 'master' || 'edge'}} |
| 38 | + |
| 39 | + # The logic below handles the npm publication: |
| 40 | + - uses: actions/setup-node@v4 |
| 41 | + with: |
| 42 | + node-version: '20.x' |
| 43 | + registry-url: 'https://registry.npmjs.org' |
| 44 | + if: ${{ steps.release.outputs.release_created }} |
| 45 | + # these if statements ensure that a publication only occurs when |
| 46 | + # a new release is created: |
| 47 | + - run: npm run build-all |
| 48 | + if: ${{ steps.release.outputs.release_created }} |
| 49 | + - run: npm publish --tag ${{ github.event.inputs.release-type }} |
| 50 | + env: |
| 51 | + NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} |
| 52 | + if: ${{ steps.release.outputs.release_created }} |
| 53 | + |
| 54 | + - name: Set Notification Messages |
| 55 | + id: set-messages |
| 56 | + if: steps.release.outputs.release_created |
| 57 | + run: | |
| 58 | + if [[ ${{ job.status }} == "success" ]]; then |
| 59 | + echo "SLACK_TITLE=Video Player ${{ steps.release.outputs.tag_name }} Deployed" >> $GITHUB_OUTPUT |
| 60 | + echo "SLACK_MESSAGE=Success :rocket: cloudinary-video-player version ${{ steps.release.outputs.tag_name }} deployed successfully" >> $GITHUB_OUTPUT |
| 61 | + echo "SLACK_FOOTER=Check it out at https://cloudinary.github.io/cloudinary-video-player/?ver=${{ github.event.inputs.release-type }}&min=true" >> $GITHUB_OUTPUT |
| 62 | + else |
| 63 | + echo "SLACK_TITLE=Video Player Deployment Failed" >> $GITHUB_OUTPUT |
| 64 | + echo "SLACK_MESSAGE=:alert: Failed to deploy cloudinary-video-player version ${{ steps.release.outputs.tag_name }}" >> $GITHUB_OUTPUT |
| 65 | + echo "SLACK_FOOTER=See log here https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}/job/${{ github.job }}" >> $GITHUB_OUTPUT |
| 66 | + fi |
| 67 | + shell: bash |
| 68 | + |
| 69 | + - name: Slack Notification |
| 70 | + if: steps.release.outputs.release_created |
| 71 | + uses: rtCamp/action-slack-notify@v2.2.0 |
| 72 | + env: |
| 73 | + SLACK_WEBHOOK: ${{ vars.FE_DEPLOYMENTS_SLACK_WEBHOOK }} |
| 74 | + SLACK_CHANNEL: 'rnd-fe-releases' |
| 75 | + SLACK_COLOR: ${{ job.status }} |
| 76 | + SLACK_TITLE: ${{ steps.set-messages.outputs.SLACK_TITLE }} |
| 77 | + SLACK_MESSAGE: ${{ steps.set-messages.outputs.SLACK_MESSAGE }} |
| 78 | + SLACK_FOOTER: ${{ steps.set-messages.outputs.SLACK_FOOTER }} |
| 79 | + |
| 80 | + - uses: gacts/purge-jsdelivr-cache@v1 |
| 81 | + if: steps.release.outputs.release_created |
| 82 | + with: |
| 83 | + url: | |
| 84 | + https://cdn.jsdelivr.net/npm/cloudinary-video-player |
| 85 | + https://cdn.jsdelivr.net/npm/cloudinary-video-player@edge |
0 commit comments