Publish #1
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 | |
on: | |
workflow_dispatch: | |
inputs: | |
versionType: | |
type: choice | |
description: '<major|minor|patch>' | |
required: true | |
default: 'minor' | |
options: | |
- major | |
- minor | |
- patch | |
jobs: | |
publish: | |
name: Publish ${{ inputs.versionType }} release | |
permissions: | |
# Give the default GITHUB_TOKEN write permission to commit and push the | |
# added or changed files to the repository. | |
contents: write | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.GH_ACCESS_TOKEN }} | |
- name: Prepare Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ vars.NODE_VERSION}} | |
cache: 'yarn' | |
- id: update-version | |
shell: bash | |
name: Update package.json version | |
# Use npm because yarn is for some reason not able to output only the version name | |
run: | | |
echo "version=$(npm version --no-git-tag-version ${{ inputs.versionType }})" >> $GITHUB_OUTPUT | |
git add . | |
- uses: planetscale/[email protected] | |
name: Commit new version | |
with: | |
commit_message: "🤖 Release ${{steps.update-version.outputs.version}}" | |
repo: ${{ github.repository }} | |
branch: main | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Checkout release branch | |
shell: bash | |
run: | | |
git checkout -b release/${{steps.update-version.outputs.version}} | |
git push origin release/${{steps.update-version.outputs.version}} | |
- name: Install | |
run: yarn install --frozen-lockfile | |
- name: Build | |
run: yarn run build | |
- name: Install prod dependencies | |
run: rm -rf node_modules && yarn install --production --frozen-lockfile | |
- name: Add node_modules and dist | |
shell: bash | |
run: | | |
git add --force dist/ | |
git add --force node_modules/ | |
- uses: planetscale/[email protected] | |
name: Commit node_modules and dist | |
with: | |
commit_message: "🤖 Build ${{steps.update-version.outputs.version}}" | |
repo: ${{ github.repository }} | |
branch: release/${{steps.update-version.outputs.version}} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create tag | |
id: tag | |
shell: bash | |
run: | | |
git tag ${{steps.update-version.outputs.version}} | |
git push origin ${{steps.update-version.outputs.version}} | |
git push origin --delete release/${{steps.update-version.outputs.version}} | |
echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT | |
- name: 'Build Changelog' | |
id: build_changelog | |
uses: mikepenz/release-changelog-builder-action@v4 | |
with: | |
token: '${{ github.token }}' | |
configurationJson: | | |
{ | |
"categories": [ | |
{ | |
"title": "## 🚀 Features", | |
"labels": ["feature"] | |
}, | |
{ | |
"title": "## 🐛 Fixes", | |
"labels": ["fix"] | |
}, | |
{ | |
"title": "## 💬 Other", | |
"labels": ["other"] | |
}, | |
{ | |
"title": "## 📦 Dependencies", | |
"labels": ["dependencies"] | |
}, | |
{ | |
"title": "## ❓ Uncategorized", | |
"labels": [] | |
} | |
] | |
} | |
- name: Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
draft: true | |
body: ${{steps.build_changelog.outputs.changelog}} | |
name: ${{steps.update-version.outputs.version}} | |
tag_name: ${{steps.update-version.outputs.version}} | |
target_commitish: ${{ steps.tag.outputs.sha }} |