fix(ci): auto releasing w/ dist from temp branch #38
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: ${{ github.head_ref }}-release-${{ github.run_number }} | |
permissions: | |
contents: write | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Rebuild and push the dist/ directory | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
npm run dist | |
git diff ./dist | |
git checkout -b ${{ env.TEMP_BRANCH }} | |
git add ./dist --force | |
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com" | |
git config --global user.name "${GITHUB_ACTOR}" | |
git add . | |
git commit -m "Rebuild dist/ directory" | |
git push -u origin HEAD:${{ env.TEMP_BRANCH }} | |
- name: Conventional Changelog Update | |
uses: TriPSs/conventional-changelog-action@v5 | |
id: changelog | |
continue-on-error: true | |
with: | |
git-branch: ${{ env.TEMP_BRANCH }} | |
github-token: ${{ github.token }} | |
skip-version-file: 'true' | |
skip-commit: 'true' | |
skip-on-empty: 'true' | |
pre-release: true | |
- name: Release | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
if [ -z "${{ steps.changelog.outputs.tag }}" ]; then | |
echo "No tag found, exiting" | |
exit 1 | |
else | |
gh release create ${{ steps.changelog.outputs.tag }} --title ${{ steps.changelog.outputs.tag }} --generate-notes --clobber | |
fi | |
cleanup: | |
name: Cleanup | |
if: always() | |
needs: release | |
env: | |
TEMP_BRANCH: ${{ github.head_ref }}-release-${{ github.run_number }} | |
permissions: | |
contents: write | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Cleanup | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
git checkout main | |
git pull | |
git worktree prune | |
git push --delete origin ${{ env.TEMP_BRANCH }} |