chore: improve release flow #309
This file contains 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 Edge | |
on: | |
push: | |
branches: | |
- 'master' | |
workflow_dispatch: | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- run: npm ci | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: '20.x' | |
registry-url: 'https://registry.npmjs.org' | |
- name: Get current version from package.json | |
id: get_version | |
run: | | |
current_version=$(node -p "require('./package.json').version") | |
echo "current_version=${current_version}" >> $GITHUB_OUTPUT | |
- name: Calculate next version | |
id: get_next_version | |
run: | | |
next_version=$(npx semver ${{ steps.get_version.outputs.current_version }} -i patch) | |
echo "Next patch version: $next_version" | |
echo "version=$next_version" >> $GITHUB_OUTPUT | |
- name: Configure Git | |
run: | | |
git config user.name "${{ github.actor }}" | |
git config user.email "${{ github.actor }}@users.noreply.github.com" | |
- name: Checkout or create edge branch | |
run: | | |
git fetch origin | |
if git rev-parse --verify origin/${{ steps.get_next_version.outputs.version }}-edge; then | |
git checkout ${{ steps.get_next_version.outputs.version }}-edge | |
git merge master --allow-unrelated-histories | |
else | |
git checkout -b ${{ steps.get_next_version.outputs.version }}-edge | |
fi | |
- name: Bump version | |
id: bump_version | |
run: | | |
new_version=$(npm version prerelease --preid=edge) | |
echo "New edge version: $new_version" | |
echo "new_version=${new_version}" >> $GITHUB_OUTPUT | |
- name: Push version | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
git push origin ${{ steps.get_next_version.outputs.version }}-edge | |
- run: npm run build-all | |
- run: npm publish --tag edge | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Set Notification Messages | |
id: set-messages | |
run: | | |
if [[ ${{ job.status }} == "success" ]]; then | |
echo "SLACK_TITLE=Video Player ${{ steps.bump_version.outputs.new_version }} Deployed" >> $GITHUB_OUTPUT | |
echo "SLACK_MESSAGE=Success :rocket: cloudinary-video-player version ${{ steps.bump_version.outputs.new_version }} deployed successfully" >> $GITHUB_OUTPUT | |
echo "SLACK_FOOTER=Check it out at https://cloudinary.github.io/cloudinary-video-player/?ver=edge&min=true" >> $GITHUB_OUTPUT | |
else | |
echo "SLACK_TITLE=Video Player Deployment Failed" >> $GITHUB_OUTPUT | |
echo "SLACK_MESSAGE=:alert: Failed to deploy cloudinary-video-player version ${{ steps.bump_version.outputs.new_version }}" >> $GITHUB_OUTPUT | |
echo "SLACK_FOOTER=See log here https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}/job/${{ github.job }}" >> $GITHUB_OUTPUT | |
fi | |
shell: bash | |
- name: Slack Notification | |
uses: rtCamp/[email protected] | |
env: | |
SLACK_WEBHOOK: ${{ vars.FE_DEPLOYMENTS_SLACK_WEBHOOK }} | |
SLACK_CHANNEL: 'rnd-fe-releases' | |
SLACK_COLOR: ${{ job.status }} | |
SLACK_TITLE: ${{ steps.set-messages.outputs.SLACK_TITLE }} | |
SLACK_MESSAGE: ${{ steps.set-messages.outputs.SLACK_MESSAGE }} | |
SLACK_FOOTER: ${{ steps.set-messages.outputs.SLACK_FOOTER }} | |
- uses: gacts/purge-jsdelivr-cache@v1 | |
with: | |
url: | | |
https://cdn.jsdelivr.net/npm/cloudinary-video-player@edge |