A GitHub Action for publishing JavaScript Actions! It's designed to act on new releases, and updates the tag with a compiled JS file, using @vercel/ncc
. The process looks like this:
- Reads the
main
property in yourpackage.json
- Force pushes
action.yml
and the above file to the release's tag - Force pushes to the major version tag (ex:
v1.0.0
->v1
)
This repository even uses it! @vercel/ncc
supports TypeScript out of the box π
name: Publish
on:
release:
types: [published, edited]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
ref: ${{ github.event.release.tag_name }}
- name: Install deps and build
run: npm ci && npm run build
- uses: JasonEtco/build-and-tag-action@v1
env:
GITHUB_TOKEN: ${{ github.token }}
You can also use this action with other events - you'll just need to specify a tag_name
(see below).
The two important thing you'll need to set in your action are the main
field and the build
script. Here's an example of a minimal package.json
that will use @vercel/ncc
to compile your action to dist/index.js
, update your action.yml
file to use the node12
runtime and point build-and-tag-action
at the compiled file:
{
"name": "your-action-name",
"main": "dist/index.js",
"scripts": {
"build": "npx @vercel/ncc build && npx convert-action"
}
}
Your package.json
will probably contain a dependencies
section, in addition to other fields such as license
.
tag_name
The tag to update. If the workflow event is release
, it will use the tag_name
from the event payload. This option can be useful when using this action in a workflow with other actions that generate a release:
- uses: fictional/releaser@v1 # Not a real action!
id: releaser
- uses: JasonEtco/build-and-tag-action@v1
with:
tag_name: ${{ steps.releaser.outputs.tag_name }}
The guide to JavaScript Actions recommends including node_modules
in your repository, and manual steps to following the versioning recommendations. There are anti-patterns there that just don't sit right with me; so we can enable the same workflow, automatically!
This Action is heavily inspired by mheap/github-action-auto-compile-node & Actions-R-Us/actions-tagger. This is more or less a combination of those two Actions, meant to work together.