Merge #86
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: | |
concurrency: | |
group: ${{ github.workflow }} | |
cancel-in-progress: true | |
jobs: | |
release: | |
name: Release | |
env: | |
branch: temp-${{ github.run_number }} | |
outputs: | |
next: ${{ steps.semver.outputs.next }} | |
permissions: | |
contents: write | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Get Semver | |
id: semver | |
continue-on-error: true | |
uses: ietf-tools/semver-action@v1 | |
with: | |
token: ${{ github.token }} | |
- name: Git Setup | |
if: ${{ 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.branch }} | |
- name: Rebuild ./dist | |
if: ${{ steps.semver.outputs.next }} | |
run: | | |
npm run dist | |
git add ./dist --force | |
git commit -m "Rebuild dist/ directory" | |
git push -u origin HEAD:${{ env.branch }} | |
- name: Tag and Release (Major) | |
if: ${{ steps.semver.outputs.next }} | |
env: | |
GH_TOKEN: ${{ github.token }} | |
tag: ${{ steps.semver.outputs.nextMajor }} | |
run: | | |
git tag -f ${{ env.tag }} | |
git push -f origin tag ${{ env.tag }} | |
if [ $(gh release view ${{ env.tag }} --json name -q .name) ]; then | |
gh release edit ${{ env.tag }} --title ${{ env.tag }} --tag ${{ env.tag }} | |
else | |
gh release create ${{ env.tag }} --title ${{ env.tag }} --generate-notes | |
fi | |
- name: Tag and Release (Semver) | |
if: ${{ steps.semver.outputs.next }} | |
env: | |
GH_TOKEN: ${{ github.token }} | |
tag: ${{ steps.semver.outputs.next }} | |
run: | | |
git tag ${{ env.tag }} | |
git push origin tag ${{ env.tag }} | |
if [ $(gh release view ${{ env.tag }} --json name -q .name) ]; then | |
gh release delete ${{ env.tag }} --yes | |
fi | |
gh release create ${{ env.tag }} --title ${{ env.tag }} --generate-notes | |
- name: Cleanup | |
if: always() | |
run: | | |
if [ "$(git ls-remote origin ${{ env.branch }})" ]; then | |
git push --delete origin ${{ env.branch }} | |
else | |
echo "Cleanup not required" | |
fi |