Skip to content

Publish GitHub Action with ncc

Actions

About

Publish your GitHub Action with ncc
v3.1.9
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).

What's new

Please refer to the release page for the latest release notes.

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
draft_release_pr_reminder Post a reminder comment on the merged PR when creating a draft release No false
comment_on_linked_issues Comment on closed issues linked to PRs in the release notes to notify followers of the release (uses GraphQL closingIssuesReferences; idempotent — updates existing comment on rerun). Comments are posted for both published and draft releases; the comment is updated if the version changes on a subsequent run. 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

Permissions

The action requires specific permissions depending on features used:

Permission Required Purpose
contents: write Yes Push tags and create releases
pull-requests: write No Post reminder comment on merged PR (draft_release_pr_reminder: true)
issues: write No Comment on linked issues (comment_on_linked_issues: true)

Example with all permissions:

permissions:
  contents: write
  pull-requests: write # only needed if using draft_release_pr_reminder
  issues: write # only needed if using comment_on_linked_issues

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@v6
      - name: install ncc
        run: npm i -g @vercel/ncc
      - uses: joshjohanning/publish-github-action@v3
        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
          draft_release_pr_reminder: true

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
v3.1.9
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.