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
10 changes: 9 additions & 1 deletion .github/workflows/beta-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ jobs:
VERSION="$(echo "$PROPERTIES" | grep "^version:" | cut -f2- -d ' ')"
VERSION_WITH_BUILDNUMBER="$VERSION-beta+$BUILDNUMBER"
echo "betaVersion=$VERSION-beta" >> $GITHUB_ENV

# Read before the version gets the beta suffix: the changelog section is named after the plain version
RELEASE_NOTE="./build/tmp/beta_release_note.txt"
mkdir -p "$(dirname "$RELEASE_NOTE")"
./gradlew getChangelog --project-version "$VERSION" --no-header --console=plain -q > "$RELEASE_NOTE" 2>/dev/null \
|| ./gradlew getChangelog --unreleased --no-header --console=plain -q > "$RELEASE_NOTE"
echo "releaseNote=$RELEASE_NOTE" >> $GITHUB_ENV

sed -i "/pluginVersion = / s/ = .*/ = $VERSION_WITH_BUILDNUMBER/" gradle.properties
echo "Version: $VERSION_WITH_BUILDNUMBER"

Expand Down Expand Up @@ -70,7 +78,7 @@ jobs:
--target "${{ github.head_ref }}" \
--title "v${{ env.betaVersion }}" \
--prerelease \
--notes "This is a prerelease of the next version of the plugin. Checkout the pull request from master to release for the changelog."
--notes-file "${{ env.releaseNote }}"

# Upload artifact as a release asset
- name: Upload Release Asset
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ on:
# Trigger the workflow on pushes to only the 'main' branch (this avoids duplicate checks being run e.g. for dependabot pull requests)
push:
branches: [main]
# Trigger the workflow on any pull request
# Trigger the workflow on any pull request, except the ones to 'release': their head is main, whose push build
# already runs for the same commit and shows up in the pull request
pull_request:
branches-ignore: [release]

jobs:

Expand Down Expand Up @@ -69,8 +71,10 @@ jobs:
PROPERTIES="$(./gradlew properties --console=plain -q)"
VERSION="$(echo "$PROPERTIES" | grep "^version:" | cut -f2- -d ' ')"
NAME="$(echo "$PROPERTIES" | grep "^pluginName:" | cut -f2- -d ' ')"
CHANGELOG="$(./gradlew getChangelog --unreleased --no-header --console=plain -q)"

# The section of the version, which the "Prepare release" workflow creates, or the unreleased one without it
CHANGELOG="$(./gradlew getChangelog --project-version "$VERSION" --no-header --console=plain -q 2>/dev/null \
|| ./gradlew getChangelog --unreleased --no-header --console=plain -q)"

echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "name=$NAME" >> $GITHUB_OUTPUT

Expand Down
83 changes: 83 additions & 0 deletions .github/workflows/prepare-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# GitHub Actions Workflow that prepares a release: it raises the pluginVersion, moves the Unreleased section of the
# changelog under that version and opens a pull request to main with both. Once it is merged, the Build workflow
# creates the release draft with the notes of that version, and the main -> release pull request publishes the beta.
# Started by hand from the Actions tab.

name: Prepare Release
on:
workflow_dispatch:
inputs:
version:
description: Version to release, e.g. 0.6.2
required: true
type: string

jobs:

prepare-release:
name: Prepare Release
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:

# Check out current repository
- name: Fetch Sources
uses: actions/checkout@v7
with:
ref: main

# Setup Java 21 environment for the next steps
- name: Setup Java
uses: actions/setup-java@v6
with:
distribution: zulu
java-version: 21

# Setup Gradle
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v6
with:
gradle-home-cache-cleanup: true

# Raise the version and move the Unreleased section under it
- name: Patch Version and Changelog
env:
VERSION: ${{ inputs.version }}
run: |
if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "::error::'$VERSION' is not a version like 0.6.2"
exit 1
fi

UNRELEASED="$(./gradlew getChangelog --unreleased --no-header --console=plain -q)"
if [ -z "$(echo "$UNRELEASED" | tr -d '[:space:]')" ]; then
echo "::error::The Unreleased section of CHANGELOG.md is empty"
exit 1
fi

sed -i "/pluginVersion = / s/ = .*/ = $VERSION/" gradle.properties
./gradlew patchChangelog

# Open the pull request to main. It is created with the GITHUB_TOKEN, so no workflows run for it
- name: Create Pull Request
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ inputs.version }}
run: |
BRANCH="prepare-release-v$VERSION"

git config user.email "action@github.com"
git config user.name "GitHub Action"

git checkout -b "$BRANCH"
git commit -m "Prepare the $VERSION release" gradle.properties CHANGELOG.md
git push --set-upstream origin "$BRANCH"

mkdir -p build/tmp
./gradlew getChangelog --project-version "$VERSION" --no-header --console=plain -q > build/tmp/release_note.txt
gh pr create \
--base main \
--title "Prepare the $VERSION release" \
--body-file build/tmp/release_note.txt
Loading
Loading