Skip to content

Commit

Permalink
👷‍♀️ Move publishing inside single workflow
Browse files Browse the repository at this point in the history
At the moment, we have two Github Action workflows:

  - `test.yml`: runs build and test, then tags when bumping the version
    in `main`
  - `publish.yml`: releases the package when a new tag is published

The issue with this setup is that the built-in `GITHUB_TOKEN`
[will not trigger another workflow][1], so we had to add a separate
PAT with write permissions to our repos, which was a bit of a
security concern.

In order to avoid the need for this extra token, with its associated
risks and administrative overheads (like rotating), this change
combines our workflows into a single workflow.

We tweak the `tag.sh` to `release.sh`, and it's now also in charge of
publishing (since it knows when we've pushed a new tag).

[1]: https://docs.github.com/en/actions/using-workflows/triggering-a-workflow#triggering-a-workflow-from-a-workflow
  • Loading branch information
alecgibson committed Jan 18, 2024
1 parent c0297f5 commit eaabc2a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 35 deletions.
18 changes: 7 additions & 11 deletions .github/workflows/test.yml → .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test
name: CI

on:
push:
Expand All @@ -13,14 +13,10 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
# Use PAT instead of default Github token, because the default
# token deliberately will not trigger another workflow run
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
- uses: actions/setup-node@v3
with:
node-version: '18.x'
node-version: '20.x'
registry-url: 'https://npm.pkg.github.com'
- uses: pnpm/action-setup@v2
- name: Install
Expand All @@ -31,6 +27,6 @@ jobs:
run: pnpm build
- name: Test
run: pnpm test
- name: Tag
if: ${{ github.ref == 'refs/heads/main' }}
run: ./tag.sh
- name: Release
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
run: ./release.sh
24 changes: 0 additions & 24 deletions .github/workflows/publish.yml

This file was deleted.

2 changes: 2 additions & 0 deletions tag.sh → release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@ git add --all packages/floating-vue/dist/
git commit --message "Release version $VERSION"
git tag $VERSION
git push origin refs/tags/$VERSION

npm publish -w packages/floating-vue

0 comments on commit eaabc2a

Please sign in to comment.