Publish release #122
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: Publish release | |
on: | |
workflow_dispatch: | |
inputs: | |
type: | |
description: 'Type of publish (one of: rc, main, both, hotfix)' | |
required: true | |
default: 'rc' | |
jobs: | |
publish_main: | |
runs-on: ubuntu-latest | |
steps: | |
- | |
name: Setup environment | |
id: set-vars | |
run: | | |
if [[ "${{ github.event.inputs.type }}" == "both" || "${{ github.event.inputs.type }}" == "main" ]]; then | |
echo "::set-output name=main::true" | |
elif [[ "${{ github.event.inputs.type }}" == "hotfix" ]]; then | |
echo "::set-output name=main::true" | |
echo "::set-output name=hotfix::true" | |
fi | |
- | |
name: Setup Node | |
if: ${{ steps.set-vars.outputs.main == 'true' }} | |
uses: actions/setup-node@v1 | |
with: | |
node-version: 16 | |
- | |
name: Checkout `main` branch | |
if: ${{ steps.set-vars.outputs.main == 'true' }} | |
uses: actions/checkout@v3 | |
with: | |
token: ${{ secrets.GH_TOKEN }} | |
ref: main | |
- | |
name: Configure git | |
if: ${{ steps.set-vars.outputs.main == 'true' }} | |
run: | | |
git config user.email "${{ github.actor }}@users.noreply.github.com" | |
git config user.name ${{ github.actor }} | |
git fetch --all | |
- | |
name: Merge down from `main` -> `rc` -> `develop` | |
if: ${{ steps.set-vars.outputs.main == 'true' }} | |
run: | | |
git checkout -B release-candidate origin/release-candidate | |
git merge main | |
git checkout -B develop origin/develop | |
git merge release-candidate | |
git checkout main | |
- | |
name: Merge `release-candidate` -> `main` | |
if: ${{ steps.set-vars.outputs.main == 'true' && steps.set-vars.outputs.hotfix != 'true' }} | |
run: git merge release-candidate | |
- | |
name: Initialize and build code | |
if: ${{ steps.set-vars.outputs.main == 'true' }} | |
run: | | |
npm set unsafe-perm true | |
npm ci && npm run build | |
- | |
name: Publish release | |
if: ${{ steps.set-vars.outputs.main == 'true' }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | |
run: npm run release -- --ci --github.release --no-npm-publish | |
- | |
name: Update and push code to `release-candidate` and `develop` | |
if: ${{ steps.set-vars.outputs.main == 'true' }} | |
run: | | |
git checkout release-candidate | |
git merge main | |
git push | |
git checkout develop | |
git merge main | |
git push | |
- | |
name: Send Discord notification | |
if: ${{ steps.set-vars.outputs.main == 'true' }} | |
run: | | |
# Prepare notification body | |
echo '{"embeds":[{"title":"**Release Published**","description":"```' > embed.json | |
git log -2 --pretty=%B >> embed.json | |
echo '```","color":3581519}]}' >> embed.json | |
cat embed.json | |
# Send notification | |
res=$(curl -X POST ${{ secrets.DISCORD_RELEASE_WEBHOOK }} -H "Content-Type: application/json" -d @embed.json) || exit 1 | |
publish_rc: | |
runs-on: ubuntu-latest | |
needs: publish_main | |
steps: | |
- | |
name: Setup environment | |
id: set-vars | |
run: | | |
if [[ "${{ github.event.inputs.type }}" == "both" || "${{ github.event.inputs.type }}" == "rc" ]]; then | |
echo "::set-output name=rc::true" | |
fi | |
- | |
name: Setup Node | |
if: ${{ steps.set-vars.outputs.rc == 'true' }} | |
uses: actions/setup-node@v1 | |
with: | |
node-version: 16 | |
- | |
name: Checkout `release-candidate` branch | |
if: ${{ steps.set-vars.outputs.rc == 'true' }} | |
uses: actions/checkout@v3 | |
with: | |
token: ${{ secrets.GH_TOKEN }} | |
ref: release-candidate | |
- | |
name: Configure git | |
if: ${{ steps.set-vars.outputs.rc == 'true' }} | |
run: | | |
git config user.email "${{ github.actor }}@users.noreply.github.com" | |
git config user.name ${{ github.actor }} | |
git fetch --all | |
- | |
name: Merge down from `rc` -> `develop` | |
if: ${{ steps.set-vars.outputs.rc == 'true' }} | |
run: | | |
git checkout -B develop origin/develop | |
git merge release-candidate | |
git checkout release-candidate | |
- | |
name: Merge `develop` -> `release-candidate` | |
if: ${{ steps.set-vars.outputs.rc == 'true' }} | |
run: git merge develop | |
- | |
name: Initialize and build code | |
if: ${{ steps.set-vars.outputs.rc == 'true' }} | |
run: | | |
npm set unsafe-perm true | |
npm ci && npm run build | |
- | |
name: Publish pre-release | |
if: ${{ steps.set-vars.outputs.rc == 'true' }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | |
run: npm run release -- --ci --preReleaseId=rc --github.preRelease --no-npm-publish | |
- | |
name: Update and push code to `develop` | |
if: ${{ steps.set-vars.outputs.rc == 'true' }} | |
run: | | |
git checkout develop | |
git merge release-candidate | |
git push | |
- | |
name: Send Discord notification | |
if: ${{ steps.set-vars.outputs.rc == 'true' }} | |
run: | | |
# Prepare notification body | |
echo '{"embeds":[{"title":"**Release Candidate Published**","description":"```' > embed.json | |
git log -1 --pretty=%B >> embed.json | |
echo '```","color":3581519}]}' >> embed.json | |
cat embed.json | |
# Send notification | |
res=$(curl -X POST ${{ secrets.DISCORD_RELEASE_WEBHOOK }} -H "Content-Type: application/json" -d @embed.json) || exit 1 |