Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ on:
push:
tags:
- "v*"
# tag-release (in validate.yml) pushes the tag using the default
# GITHUB_TOKEN, which GitHub does not allow to trigger other workflows
# (loop prevention), so it explicitly re-dispatches this workflow instead
# of relying on the push trigger above to fire. The tag input tells this
# run which tag to check out and release, since a workflow_dispatch run
# has no tag ref of its own to infer one from.
workflow_dispatch:
inputs:
tag:
description: "Tag to release (e.g. v0.3.0)"
required: true

permissions:
contents: write
Expand All @@ -14,6 +25,8 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.tag || github.ref_name }}

- uses: actions/setup-node@v4
with:
Expand Down Expand Up @@ -43,5 +56,6 @@ jobs:
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.event.inputs.tag || github.ref_name }}
files: release.tar.gz
generate_release_notes: true
11 changes: 11 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,16 @@ jobs:
runs-on: ubuntu-latest
permissions:
contents: write
actions: write

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Tag plugin.json's version if untagged
env:
GH_TOKEN: ${{ github.token }}
run: |
VERSION=$(node -pe "JSON.parse(require('fs').readFileSync('plugin.json', 'utf8')).version")
TAG="v${VERSION}"
Expand All @@ -53,3 +56,11 @@ jobs:
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git tag "$TAG"
git push origin "$TAG"

# A tag pushed with the default GITHUB_TOKEN does not trigger
# other workflows' push:tags events (GitHub's loop-prevention),
# so explicitly dispatch release.yml instead of relying on the
# push trigger to fire. release.yml's workflow_dispatch only
# exists on main, not on the tag itself, so dispatch against
# main and pass the tag as an input for it to check out.
gh workflow run release.yml --repo "${{ github.repository }}" -f tag="$TAG"
Loading