feat: semver and major releases on merge #65
Workflow file for this run
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: Merge | |
on: | |
# push: | |
# branches: [main] | |
# paths: | |
# - 'src/**' | |
# - 'package-lock.json' | |
# - 'package.json' | |
# - 'tsconfig.json' | |
# - 'action.yml' | |
# workflow_dispatch: | |
pull_request: | |
concurrency: | |
group: ${{ github.workflow }} | |
cancel-in-progress: true | |
jobs: | |
release: | |
name: Release | |
env: | |
TEMP_BRANCH: temp-${{ github.run_number }} | |
# outputs: | |
# tag: ${{ steps.changelog.outputs.tag }} | |
permissions: | |
contents: write | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Get Next Semver | |
id: semver | |
uses: ietf-tools/semver-action@v1 | |
with: | |
token: ${{ github.token }} | |
- name: Set up Branch and User | |
if: ${{ steps.changelog.outputs.tag }} | |
env: | |
GH_TOKEN: ${{ github.token }} | |
TAG: ${{ steps.semver.outputs.next }} | |
run: | | |
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com" | |
git config --global user.name "${GITHUB_ACTOR}" | |
git checkout -b ${{ env.TEMP_BRANCH }} | |
git push -u origin HEAD:${{ env.TEMP_BRANCH }} | |
- name: Rebuild and push ./dist | |
if: ${{ steps.changelog.outputs.tag }} | |
env: | |
GH_TOKEN: ${{ github.token }} | |
TAG: ${{ steps.semver.outputs.next }} | |
run: | | |
set -x | |
npm run dist | |
git add ./dist --force | |
git add . | |
git commit -m "Rebuild dist/ directory" | |
git diff ./dist | |
- name: Push Tag and Release | |
if: ${{ steps.changelog.outputs.tag }} | |
env: | |
GH_TOKEN: ${{ github.token }} | |
TAG: ${{ steps.semver.outputs.next }} | |
run: | | |
set -x | |
git tag ${{ env.TAG }} | |
git push origin tag ${{ env.TAG }} | |
gh release create ${{ env.TAG }} --title ${{ env.TAG }} --generate-notes | |
git push --delete origin ${{ env.TEMP_BRANCH }} | |
cleanup: | |
name: Cleanup | |
if: failure() || cancelled() | |
needs: release | |
env: | |
TEMP_BRANCH: temp-${{ github.run_number }} | |
permissions: | |
contents: write | |
runs-on: ubuntu-latest | |
steps: | |
- name: Cleanup | |
run: git push --delete origin ${{ env.TEMP_BRANCH }} |