fix(release): Fix failing release pipeline when there is no releaseab… #20
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: | |
push: | |
branches: | |
- "main" | |
workflow_dispatch: | |
jobs: | |
prerelease: | |
name: Release | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: pnpm/action-setup@v2 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: .node-version | |
cache: pnpm | |
registry-url: "https://registry.npmjs.org/" | |
scope: sit-onyx | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: 📦 Install dependencies | |
run: pnpm install | |
- name: 👷 Build packages | |
run: pnpm build-all | |
- name: 🤖 Configure Git Bot | |
run: | | |
git config user.name "Release Bot[bot]" | |
git config user.email "[email protected]" | |
- name: ⛴️ Version and Publish | |
if: ${{ github.ref == 'refs/heads/main' }} | |
run: | | |
npx changeset version | |
npx changeset publish | |
git add --all | |
if [[ `git status --porcelain` ]]; then | |
git commit --amend --no-edit | |
git push --follow-tags | |
else | |
echo "No new version. Nothing to commit." | |
fi | |
- name: 📸 Snapshot and Publish | |
if: ${{ github.ref != 'refs/heads/main' }} | |
run: | | |
# [Snapshot release fails if repository is in pre-release mode](https://github.com/changesets/changesets/issues/1195) | |
rm -f .changeset/pre.json | |
# Add empty changeset so we always have a new snapshot release for each new run | |
npx changeset add --empty | |
npx changeset version --snapshot | |
npx changeset publish --tag snapshot |