Create a URL for a GitHub release
This is a simple, but useful, action for creating GitHub release URLs.
---
name: release
on:
pull_request:
branches:
- main
types:
- closed
env:
REF: ${{ github.event.pull_request.merge_commit_sha }}
REF_NAME: ${{ format('{0}@{1}', github.base_ref, github.event.pull_request.merge_commit_sha) }}
jobs:
preflight:
if: github.event.pull_request.merged && startsWith(github.head_ref, 'release/')
permissions:
contents: read
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.environment.outputs.tag }}
url: ${{ steps.environment.outputs.url }}
version: ${{ steps.version.outputs.manifest }}
steps:
- id: checkout
name: Checkout ${{ env.REF_NAME }}
uses: actions/[email protected]
with:
ref: ${{ env.REF }}
- id: version
name: Get release version
uses: flex-development/[email protected]
- id: tag-prefix
name: Get release tag prefix
uses: flex-development/[email protected]
with:
data: grease.config.json
filter: .tagprefix
- id: environment
name: Get release url
uses: flex-development/[email protected]
with:
tag-prefix: ${{ steps.tag-prefix.outputs.result }}
version: ${{ steps.version.outputs.manifest }}
publish:
needs: preflight
runs-on: ubuntu-latest
environment:
name: release
url: ${{ needs.preflight.outputs.url }}
env:
GITHUB_TOKEN: ${{ secrets.GH_REPO_TOKEN }}
NOTES_FILE: RELEASE_NOTES.md
steps:
- id: checkout
name: Checkout ${{ env.REF_NAME }}
uses: actions/[email protected]
with:
fetch-depth: 0
persist-credentials: true
ref: ${{ env.REF }}
token: ${{ env.GITHUB_TOKEN }}
- id: gpg-import
name: Import GPG key
uses: crazy-max/[email protected]
with:
git_config_global: true
git_push_gpgsign: false
git_tag_gpgsign: true
git_user_signingkey: true
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
trust_level: 5
- id: node
name: Setup Node.js
uses: actions/[email protected]
with:
cache: yarn
cache-dependency-path: yarn.lock
node-version-file: .nvmrc
- id: yarn
name: Install dependencies
run: yarn --no-immutable && echo "$GITHUB_WORKSPACE/node_modules/.bin" >>$GITHUB_PATH
- id: pack
name: Pack project
run: yarn pack -o %s-%v.tgz
- id: release-notes
name: Generate release notes
env:
TZ: ${{ vars.TZ }}
run: grease changelog -wo $NOTES_FILE && echo "$(cat $NOTES_FILE)" >>$GITHUB_STEP_SUMMARY
- id: tag
name: Create annotated tag
run: 'grease tag -ps -m "release: {tag}" ${{ needs.preflight.outputs.version }}'
- id: publish
name: Publish release
run: |
gh release create ${{ needs.preflight.outputs.tag }} *.tgz --title=${{ needs.preflight.outputs.tag }} --notes-file=$NOTES_FILE --verify-tag
The name of the release artifact to create a download URL for (optional).
default:
${{ github.repository_owner }}
The repository owner (optional).
default:
${{ github.event.repository.name }}
The name of the repository (optional).
default:
${{ github.server_url }}
The URL of the GitHub server (optional).
The prefix to append to the release version when building the release tag component of the URL (optional).
The release version or tag to create a URL for.
The release artifact download URL.
The release tag the URLs were created with.
The release URL.
flex-development/ghr-url-action
— create a url for a github registryflex-development/npm-url-action
— create a url for the npm registry
See CONTRIBUTING.md
.
This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.