Skip to content

1.3.0

1.3.0 #8

Workflow file for this run

name: Publish
on:
release:
types: [created] # It will be triggered when a NON-draft release is created and published.
jobs:
distribute:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: master # Otherwise it defaults to the version tag missing bump commit
fetch-depth: 0 # Fetch all history
- uses: actions/setup-node@v4
with:
node-version: 22.x
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm test
- name: Clear dist folder
run: rm -rfv dist/
- name: Compile
run: npm run compile
- name: Amend dist folder to the commit
run: |-
if [[ -z $(git status -s) ]]; then
echo 'There are no changes in the distribution (dist folder)'
exit 0
fi
lastCommitSha=$(git rev-parse HEAD)
bumpCommitSha=$(git rev-list "${{ github.event.release.tag_name }}"..master | tail -1)
if [ "$lastCommitSha" != "$bumpCommitSha" ]; then
echo "Last commit ($lastCommitSha) is not same as ($bumpCommitSha)."
echo "Exiting as amending to the commit may have side effects"
exit 1
fi
git config user.name "$(git log -1 --pretty=format:'%an')" || exit 1
git config user.email "$(git log -1 --pretty=format:'%ae')" || exit 1
git add 'dist/' --force || exit 1
git commit --amend --no-edit || exit 1
git push -f || exit 1
create-package:
needs: distribute
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: master # Otherwise it defaults to the version tag missing bump commit
fetch-depth: 0 # Fetch all history
- name: Checkout to bump commit
run: git checkout "$(git rev-list "${{ github.event.release.tag_name }}"..master | tail -1)"
- run: |
mkdir "/root/artifact"
cp -r . "/root/artifact"
rm -rf "/root/artifact/.git"
rm -rf "/root/artifact/.github"
rm -rf "/root/artifact/node_modules"
- uses: actions/upload-artifact@v4
with:
name: package
path: /root/artifact
publish-package:
needs: create-package
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@v4
with:
node-version: 22.x
registry-url: https://registry.npmjs.org/
- uses: actions/download-artifact@v1
with:
name: package
- run: cd package && npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}