Skip to content

fix(ci): auto releasing w/ dist from temp branch #14

fix(ci): auto releasing w/ dist from temp branch

fix(ci): auto releasing w/ dist from temp branch #14

Workflow file for this run

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:
changelog:
name: Changelog
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.changelog.outputs.tag }}
version: ${{ steps.changelog.outputs.version }}
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Conventional Changelog Update
uses: TriPSs/conventional-changelog-action@v5
id: changelog
continue-on-error: true
with:
github-token: ${{ github.token }}
output-file: 'CHANGELOG.md'
skip-version-file: 'true'
skip-commit: 'true'
skip-on-empty: 'false'
git-push: 'true'
- uses: actions/[email protected]
with:
path: CHANGELOG.md
release:
name: Release (if necessary)
needs: changelog
if: ${{ needs.changelog.outputs.version != '' }}
env:
TEMP_BRANCH: ${{ github.head_ref }}-release-${{ github.run_number }}
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: actions/[email protected]
with:
node-version: 20.x
- uses: actions/[email protected]
with:
name: my-artifact
path: path/to/artifact
- name: Rebuild and push the dist/ directory
run: |
npm run dist
git diff ./dist
if $(git diff --ignore-space-at-eol --quiet ./dist); then
git checkout -b ${{ env.TEMP_BRANCH }}
git add ./dist
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 }}
gh release create ${{ needs.changelog.outputs.tag }} --title ${{ needs.changelog.outputs.tag }} --notes-file CHANGELOG.md
git branch -D ${{ env.TEMP_BRANCH }}
fi
# - name: Create Release
# uses: softprops/action-gh-release@v2
# continue-on-error: true
# env:
# GITHUB_TOKEN: ${{ github.token }}
# with:
# token: ${{ github.token }}
# tag_name: ${{ needs.changelog.outputs.tag }}
# name: ${{ needs.changelog.outputs.tag }}
# body: ${{ needs.changelog.outputs.clean_changelog }}