Release #264
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: Release | |
on: | |
workflow_run: | |
workflows: ['Build and test'] | |
branches: [main] | |
types: | |
- completed | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Rebuild dist | |
id: dist | |
run: | | |
npm install | |
npm run package | |
git config user.name github-actions | |
git config user.email [email protected] | |
git add --force dist/index.js | |
(git commit -m 'Publish dist' && (echo 'changed=true' >> $GITHUB_OUTPUT)) || (echo 'changed=false' >> $GITHUB_OUTPUT) | |
- name: Push rebuild dist | |
if: ${{ steps.dist.outputs.changed == 'true' }} | |
run: | | |
git push origin main | |
- name: Bump version and push tag | |
uses: anothrNick/[email protected] | |
if: ${{ steps.dist.outputs.changed == 'true' }} | |
id: version | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
WITH_V: true | |
DEFAULT_BUMP: patch | |
- name: Major version tag | |
id: major-version | |
if: ${{ (steps.dist.outputs.changed == 'true') && (steps.version.outputs.new_tag != '') }} | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
core.setOutput('tag', '${{ steps.version.outputs.new_tag }}'.split('.')[0]) | |
- name: Tag ${{ steps.major-version.outputs.tag }} | |
if: ${{ (steps.dist.outputs.changed == 'true') && (steps.version.outputs.new_tag != '') }} | |
run: | | |
git tag --force ${{ steps.major-version.outputs.tag }} | |
git push origin ${{ steps.major-version.outputs.tag }} --force | |
- name: Get current date | |
if: ${{ (steps.dist.outputs.changed == 'true') && (steps.version.outputs.new_tag != '') }} | |
id: date | |
run: echo "date=$(date --iso-8601)" >> $GITHUB_OUTPUT | |
- name: Build full ChangeLog | |
if: ${{ (steps.dist.outputs.changed == 'true') && (steps.version.outputs.new_tag != '') }} | |
run: npx conventional-changelog-cli --release-count=0 --preset=eslint --outfile="${{ runner.temp }}/FullChangeLog.md" | |
- name: Create/update major version release | |
if: ${{ (steps.dist.outputs.changed == 'true') && (steps.version.outputs.new_tag != '') }} | |
uses: ncipollo/release-action@v1 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
allowUpdates: true | |
tag: ${{ steps.major-version.outputs.tag }} | |
name: ${{ steps.version.outputs.new_tag }} (${{ steps.date.outputs.date }}) | |
bodyFile: ${{ runner.temp }}/FullChangeLog.md | |
- name: Build ChangeLog | |
if: ${{ (steps.dist.outputs.changed == 'true') && (steps.version.outputs.new_tag != '') }} | |
run: npx conventional-changelog-cli --release-count=2 --outfile="${{ runner.temp }}/ChangeLog.md" | |
- name: Create release | |
if: ${{ (steps.dist.outputs.changed == 'true') && (steps.version.outputs.new_tag != '') }} | |
uses: ncipollo/release-action@v1 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
tag: ${{ steps.version.outputs.new_tag }} | |
name: Release ${{ steps.version.outputs.new_tag }} | |
bodyFile: ${{ runner.temp }}/ChangeLog.md |