Skip to content

πŸ“¦πŸ”– A GitHub Action for publishing JavaScript Actions

License

Notifications You must be signed in to change notification settings

JasonEtco/build-and-tag-action

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

79 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“¦πŸ”–

Build and Tag action

GitHub Actions status Codecov


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 your package.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)

image

This repository even uses it! @vercel/ncc supports TypeScript out of the box 😍

Usage

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@v2
        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).

Example package.json for your project

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 node16 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.

Options

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@v2
  with:
    tag_name: ${{ steps.releaser.outputs.tag_name }}

Motivation

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.

About

πŸ“¦πŸ”– A GitHub Action for publishing JavaScript Actions

Resources

License

Stars

Watchers

Forks

Packages

No packages published