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 7230ff5 commit dcac60a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 26 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ name: Publish

on:
push:
tags:
- '*'
branches:
- master

jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '14.x'
node-version: '20.x'
registry-url: 'https://npm.pkg.github.com'
- name: Build reencode action
run: cd ./.github/actions/reencode-dictionaries && npm install && cd ../../../
Expand All @@ -22,6 +22,6 @@ jobs:
- name: "Change dictionaries encoding to UTF-8"
uses: ./.github/actions/reencode-dictionaries
- name: Publish
run: npm publish
run: ./release.sh
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
20 changes: 0 additions & 20 deletions .github/workflows/tag.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 @@ -17,3 +17,5 @@ fi

git tag $VERSION
git push origin refs/tags/$VERSION

npm publish

0 comments on commit dcac60a

Please sign in to comment.