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
86 changes: 57 additions & 29 deletions .github/workflows/package-release.yml
Original file line number Diff line number Diff line change
@@ -1,64 +1,92 @@
name: Package Release
name: Release Addon

on:
push:
tags:
- "v*"
- "[0-9]+.[0-9]+.[0-9]+"
workflow_dispatch:
inputs:
tag:
description: Tag to package, for example v0.3.1 or 0.3.1
version:
description: Release version, for example 0.3.3
required: true
type: string

permissions:
contents: write

jobs:
package-release:
release-addon:
runs-on: ubuntu-latest

steps:
- name: Resolve tag and version
id: version
- name: Validate version input
id: release
env:
INPUT_TAG: ${{ inputs.tag }}
REF_NAME: ${{ github.ref_name }}
INPUT_VERSION: ${{ inputs.version }}
run: |
tag="${REF_NAME:-$INPUT_TAG}"
if [ -z "$tag" ]; then
echo "No tag was provided." >&2
exit 1
fi

version="${tag#v}"
version="${INPUT_VERSION}"
if [ -z "$version" ]; then
echo "Resolved version is empty." >&2
echo "No version was provided." >&2
exit 1
fi

echo "tag=$tag" >> "$GITHUB_OUTPUT"
case "$version" in
[0-9]*.[0-9]*.[0-9]*)
;;
*)
echo "Version must look like 0.3.3" >&2
exit 1
;;
esac

tag="v$version"
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "tag=$tag" >> "$GITHUB_OUTPUT"

- name: Check out tagged source
- name: Check out default branch
uses: actions/checkout@v4
with:
ref: ${{ steps.version.outputs.tag }}
ref: ${{ github.event.repository.default_branch }}
fetch-depth: 0

- name: Ensure tag does not already exist
env:
TAG: ${{ steps.release.outputs.tag }}
run: |
if git rev-parse "$TAG" >/dev/null 2>&1; then
echo "Tag $TAG already exists." >&2
exit 1
fi

- name: Verify plugin.cfg version
- name: Update plugin.cfg
env:
VERSION: ${{ steps.version.outputs.version }}
VERSION: ${{ steps.release.outputs.version }}
run: |
perl -0pi -e 's/version="[^"]*"/version="$ENV{VERSION}"/' addons/godotdev_nvim_node_copy/plugin.cfg
actual_version="$(sed -n 's/^version="\(.*\)"$/\1/p' addons/godotdev_nvim_node_copy/plugin.cfg)"
if [ "$actual_version" != "$VERSION" ]; then
echo "plugin.cfg version '$actual_version' does not match tag version '$VERSION'" >&2
echo "plugin.cfg version update failed." >&2
exit 1
fi

- name: Commit release bump
env:
VERSION: ${{ steps.release.outputs.version }}
TAG: ${{ steps.release.outputs.tag }}
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add addons/godotdev_nvim_node_copy/plugin.cfg
if git diff --cached --quiet; then
echo "plugin.cfg is already set to $VERSION" >&2
exit 1
fi
git commit -m "chore: release $VERSION"
git tag "$TAG"
git push origin "HEAD:$DEFAULT_BRANCH"
git push origin "$TAG"

- name: Prepare release payload
env:
VERSION: ${{ steps.version.outputs.version }}
VERSION: ${{ steps.release.outputs.version }}
run: |
mkdir -p dist/addons
cp -R addons/godotdev_nvim_node_copy dist/addons/
Expand All @@ -68,6 +96,6 @@ jobs:
- name: Create or update GitHub release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.version.outputs.tag }}
files: dist/godotdev_nvim_node_copy-${{ steps.version.outputs.version }}.zip
tag_name: ${{ steps.release.outputs.tag }}
files: dist/godotdev_nvim_node_copy-${{ steps.release.outputs.version }}.zip
generate_release_notes: true
30 changes: 14 additions & 16 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,33 @@

This repository uses the version in `addons/godotdev_nvim_node_copy/plugin.cfg`
as the release version that Godot users will see after installing from GitHub or
the Asset Library.
the Asset Library. The release workflow updates `plugin.cfg`, commits the bump to
the default branch, creates the tag, and publishes the release artifact.

## Release flow

1. Make sure your working tree is clean.
2. Run `./scripts/prepare-release.sh 0.3.1` or `./scripts/prepare-release.sh 0.3.1 --push`.
3. If you did not use `--push`, push the branch and the tag:
- `git push origin <branch>`
- `git push origin v0.3.1`
4. Wait for GitHub Actions to run `Package Release`.
5. Verify the GitHub release contains `godotdev_nvim_node_copy-0.3.1.zip`.
1. Merge your release-ready changes into the default branch.
2. In GitHub, open `Actions` and run `Release Addon`.
3. Enter the release version, for example `0.3.3`.
4. Wait for the workflow to finish.
5. Verify the default branch contains the `plugin.cfg` bump commit.
6. Verify the GitHub release contains `godotdev_nvim_node_copy-0.3.3.zip`.

## What the script does
## What the workflow does

- updates `plugin.cfg`
- creates a release commit
- creates a `vX.Y.Z` tag
- optionally pushes the branch and tag
- pushes the default branch and tag
- uploads the packaged addon zip to the GitHub release

## Safety checks

- `scripts/prepare-release.sh` refuses to run with a dirty working tree.
- `Package Release` fails if `plugin.cfg` does not match the tag version.
- `Release Addon` rejects versions that do not look like `X.Y.Z`.
- `Release Addon` fails if the target tag already exists.
- `Validate Addon` checks semver formatting and the packaged addon layout on push
and pull request.

## Example

```bash
./scripts/prepare-release.sh 0.3.1 --push
```

Run `Release Addon` with version `0.3.3`.
Loading