Skip to content

Publish GitHub Action with ncc

Actions
Publish your GitHub Action with ncc
v2.2.0
Latest
Star (1)

Publish GitHub Action

GitHub release Immutable Releases GitHub marketplace CI Publish GitHub Action Coverage

This action creates a release branch for your GitHub Actions which will be automatically tagged and released. The release version can be defined in package.json.

Based on the tgymnich/publish-github-action action, but I wanted further customization and control over the release process (i.e.: adding ncc output and not committing node_modules directory).

Features

  • 🔐 Verified Commits - Uses GitHub API to create verified commits (when commit_node_modules is false)
  • 🏷️ Annotated Tags - Creates annotated tags via Git CLI with atomic updates (no downtime)
  • 🌐 Multi-instance Support - API URL defaults to the environment you are running in; works with GitHub.com, GitHub Enterprise Server, and GHE.com
  • 📦 Flexible Build - Automatically installs production dependencies and supports custom build commands
  • 🗂️ Selective Commits - Choose which files to include (dist, node_modules, or both)

Inputs

Input Description Required Default
github_token Token for the GitHub API Yes -
github_api_url GitHub API URL (e.g., https://api.github.com for GitHub.com or https://ghes.domain.com/api/v3 for GHES) No ${{ github.api_url }}
npm_package_command Command to build the action No npm run package
commit_node_modules Whether to commit node_modules folder. Note: When set to true, commits will NOT be verified due to API limitations with large file counts No false
commit_dist_folder Whether to commit dist folder No true
publish_minor_version Whether to publish minor version tag (e.g., v1.2) No false
publish_release_branch Whether to publish release branch (e.g., releases/v1.2.3) No false
create_release_as_draft Whether to create release as draft to allow review of the release before publishing; useful with immutable releases where changes cannot be made after publishing No false

Commit Signing Behavior

  • Verified commits (signed by GitHub) when commit_node_modules: false - Uses GitHub API for commits; tags are created locally via Git CLI
  • Unverified commits when commit_node_modules: true - Uses Git CLI due to API limitations with large file counts

Build and File Management

The action automatically handles clean builds and file management:

  • Dist folder cleaning: When commit_dist_folder: true and npm_package_command is specified, the dist/ folder is cleaned before building to ensure no stale files persist
  • Automatic file deletion: The action removes .github/ files from release commits and properly handles renamed/deleted files in the dist/ folder

Example Workflow

Note

The install ncc step is only needed if @vercel/ncc is not in your package.json devDependencies. If you already have it as a dev dependency, you can skip this step.

name: 'Publish GitHub Action'
on:
  push:
    branches:
      - main

jobs:
  publish:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
      - name: install ncc
        run: npm i -g @vercel/ncc
      - uses: joshjohanning/publish-github-action@v2
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          npm_package_command: npm run package
          commit_node_modules: false
          commit_dist_folder: true
          publish_minor_version: false
          publish_release_branch: false
          create_release_as_draft: false

Publish GitHub Action with ncc is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.

About

Publish your GitHub Action with ncc
v2.2.0
Latest

Publish GitHub Action with ncc is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.