Skip to content

Prepare a Lando plugin for publishing to a package registry.

License

Notifications You must be signed in to change notification settings

lando/prepare-release-action

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

Repository files navigation

Prepare Release Action

This action allows you to automate release steps eg bump version, compile code, bundle deps and optionally push/sync those changes back to a source repo that you've fetched with @actions/checkout. It may work with repos fetched in a different way but that use case is not tested or supported so YMMV.

It was orignally designed to help automate Lando Plugin deployment and has an easy-mode lando-plugin input, however, you should be able to use it on any javascripty project.

Inputs

All inputs are optional however if you are NOT triggering this action on a release then you will need to set version.

Name Description Default Example
version The version of the thing to be released. Must be a semver valid string. ${{ github.event.release.tag_name }} v3.14.0
bundle-dependencies A toggle to autoset bundleDependencies in package.json. false true
commands A list of commands to run to prepare the release. [] npm run prepare
meta A list of path=value strings to merge into the package.json null dist=thing
root The location of the code being prepared for release. ${{ github.workspace }} /path/to/my/project
sync A toggle to enable/disable code syncing. true false
sync-branch The target branch to use when syncing changes back to the repo. ${{ github.event.release.target_commitish || github.event.pull_request.head.ref || github.ref_name }} main
sync-email The email to use when syncing changes back to the repo. [email protected] [email protected]
sync-message The commit message to use when syncing changes back to the repo. release v%s generated by @lando/prepare-release-action RELEASE %s
sync-tags A list of other tags to sync back to the repo. [] v2
sync-token A Personal Access Token to use for git sync ops. ${{ github.token }} ${{ secrets.MY_PAT }}
sync-username The username to use when syncing changes back to the repo. github-actions w.t.riker
update-files The files to operate on with update-files-meta and update-files-header. [] CHANGELOG.md
update-files-header A header to prepend to update-files after they've been operated on. [] {{ ## NEW VERSION }}
update-files-meta The find/replace metadata to be used when updating update-files. [] NEW_VERSION=${{ github.event.release.tag_name }}
version-match A regex to help find the latest tag. Only used when version=dev. v[0-9].* [1-2].*
lando-plugin A special easy-mode setting to prepare and valdiate Lando plugins. false true

Note that sync must be set to true for the other sync-* options to do anything. Also note that in sync-message you can use %s as a placeholder for the version.

Also note that sync-username and sync-email are simply for git config purposes and DO NOT map to a GitHub user. If you want to do remote git ops as a particular user then use sync-token.

Also also note that bundle-dependencies runs after sync eg it will not push changes to bundleDependencies in your package.json back to your repo. It is intended to be used for packaging dependencies when publishing to a npm compatible package registry eg npm or npm.pkg.github.com.

Also note that while update-files-meta is expressed as KEY=VALUE it must be wrapped with double brackets like {{ KEY }} in the relevant update-files for it to be properly tokenized/replaced. See our CHANGELOG.md for an example using the below inputs:

update-files: CHANGELOG.md
update-files-header: |
  ## {{ UNRELEASED_VERSION }} - [{{ UNRELEASED_DATE }}]({{ UNRELEASED_LINK }})

update-files-meta: |
  UNRELEASED_DATE=May 4, 3000
  UNRELEASED_LINK=${{ github.repositoryUrl }}
  UNRELEASED_VERSION=v${{ github.run_id }}.${{ github.run_number }}.${{ github.run_attempt}}-build.${{ github.sha }}

Caveats

  • If your project is a shallow clone (as is the default for @actions/checkout) we will --unshallow it to a full clone in order to sync changes.
  • If you have branch or tag protection turned on you will need to make sure your rules allow the sync-token user to both write to the sync-branch and sync-tags and to allow a --force alteration of the repos tags.

Usage

Basic Usage

- name: Prepare Release
  uses: lando/prepare-release-action@v3

Advanced Usage

Lando Plugin example:

- name: Prepare Release
  uses: lando/prepare-release-action@v3
  with:
    lando-plugin: true

GitHub Action javascript action example:

- name: Prepare Release
  uses: lando/prepare-release-action@v3
  with:
    commands: |
      npm run prepare
    sync-tags: v3

Everything, everywhere, all at once:

- name: Prepare Release
  uses: lando/prepare-release-action@v3
  with:
    version: v3.1.4-riker.1
    bundle-dependencies: true
    commands: |
      touch riker
      npm run prepare
    meta: |
      jazzman=William T. Riker
      bosmang=Picard
    lando-plugin: false
    sync: true
    sync-branch: kirk-epsilon
    sync-email: [email protected]
    sync-message: "Execute evasive manuveur pattern Riker %s"
    sync-tags: |
      v1
      riker1
      number2
    sync-token: ${{ secrets.MY_PAT }}
    sync-username: w.t.riker
    update-files: CHANGELOG.md
    update-files-header: |
      ## {{ UNRELEASED_VERSION }} - [{{ UNRELEASED_DATE }}]({{ UNRELEASED_LINK }})

    update-files-meta: |
      UNRELEASED_DATE=May 4, 3000
      UNRELEASED_LINK=${{ github.repositoryUrl }}
      UNRELEASED_VERSION=v${{ github.run_id }}.${{ github.run_number }}.${{ github.run_attempt}}-build.${{ github.sha }}
    version-match: "v[0-2].*"

Changelog

We try to log all changes big and small in both THE CHANGELOG and the release notes.

Releasing

Create a release and publish to GitHub Actions Marketplace

Maintainers

Contributors

Made with contrib.rocks.

Other Resources