Skip to content

CityOfLosAngeles/fetch-latest-github-release

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

140 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fetch-latest-github-release

A tiny GitHub action to fetch the latest GitHub Release for a given repository. Originally forked from https://github.com/gregziegan/fetch-latest-release on 2023/04/27.

Development Example Test Runs Production Example Test Runs Development Jest Tests & Coverage Production Jest Tests & Coverage codecov

Inputs

Parameter Description Required Default
github_token A Github token, usually ${{ github.token }}. N ${{ github.token }}
repo_path Provide a "owner/repo" string for fetching from a different repo. If not provided the repository the composite action is ran in will be used. N The current repo

Output

  • url The HTTP URL for this release
  • assets_url: The REST API HTTP URL for this release's assets
  • upload_url: The REST API HTTP URL for uploading to this release
  • html_url: The REST API HTTP URL for this release
  • id: ''
  • node_id: The unique identifier for accessing this release in the GraphQL API
  • tag_name: The name of the release's Git tag
  • target_commitish: ''
  • name: The title of the release
  • body: The description of the release
  • draft: Whether or not the release is a draft
  • prerelease: Whether or not the release is a prerelease
  • author_id: ''
  • author_node_id: The unique identifier for accessing this release's author in the GraphQL API
  • author_url: The REST API HTTP URL for this release's author
  • author_login: The username used to login.
  • author_html_url: The HTTP URL for this release's author
  • author_type: ''
  • author_site_admin: Whether or not this user is a site administrator

Usage

Example 1: Fetch the latest release from the repository this composite action was ran from.

steps:
  - id: fetch-latest-github-release
    uses: cityoflosangeles/fetch-latest-github-release@{latest-release} # ex. v1, v2, v3 etc. See https://github.com/CityOfLosAngeles/fetch-latest-github-release/releases

Example 2: Fetch the latest release from another repository. Make sure the generated token passed in has the appropriate permissions.

steps:
  - id: fetch-latest-github-release
    uses: cityoflosangeles/fetch-latest-github-release@{latest-release} # ex. v1, v2, v3 etc. See https://github.com/CityOfLosAngeles/fetch-latest-github-release/releases
    with:
      github_token: ${{ github.token }}
      repo_path: 'user/repo-name'

You will retrieve the output from subsequent GitHub Actions steps like:

- name: 'Obtain Latest Tag Name & Run a Cool Process Against It'
  uses: 'hiimbex/some-cool-action@v1'
  with:
    version: ${{ steps.fetch-latest-github-release.outputs.tag_name }}

steps.fetch-latest-github-release.outputs.tag_name is important, you can fetch other outputs that are defined in action.yml.

CI / Unit Tests

To run the tests locally, run npm test. The unit tests have been updated to work with the latest GitHub Actions dependencies using proper mocking strategies for ESM modules.

Build Instructions

This project uses Vercel NCC to bundle the GitHub Action into a single distributable file.

Building the Action

To build the action, run:

npm run build

This will:

  • Use NCC to bundle all dependencies from src/index.ts into a single file at dist/index.cjs.
  • Generate a source map for debugging.

Notes

  • The output file is dist/index.cjs (CommonJS format).
  • You do not need to ship node_modules with your action; everything is bundled.
  • If you change the source code, always re-run npm run build before committing or releasing.

Example package.json scripts

"scripts": {
  "build": "ncc build src/index.ts -o dist --source-map && mv dist/index.js dist/index.cjs",
  ...
}

Referencing in action.yml

In your action.yml, set the entrypoint to dist/index.cjs:

runs:
  using: 'node20'
  main: 'dist/index.cjs'

About

A tiny GitHub action to fetch the latest GitHub Release for a given repository. Originally forked from https://github.com/gregziegan/fetch-latest-release.

Resources

License

Security policy

Stars

Watchers

Forks

Contributors