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
1 change: 1 addition & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: Pull request
on:
pull_request:
types: [ opened, reopened, synchronize ]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
Expand Down
14 changes: 13 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
name: Release
on: [ workflow_dispatch ]
on:
workflow_dispatch:
inputs:
version:
description: Version to release, e.g. 14.3.0
required: true
permissions:
contents: read
jobs:
Expand All @@ -20,6 +25,7 @@ jobs:
runs-on: ubuntu-latest
needs: build
permissions:
actions: write
contents: write
pull-requests: write
steps:
Expand All @@ -43,6 +49,7 @@ jobs:
- name: Publish release
run: bash github-build.sh
env:
RELEASE_VERSION: ${{ inputs.version }}
MAVEN_USERNAME: ${{ secrets.OSS_USER_TOKEN_KEY }}
MAVEN_PASSWORD: ${{ secrets.OSS_USER_TOKEN_PASS }}
GPG_PASSPHRASE: ${{ secrets.GPG_SIGNING_PASSWORD }}
Expand All @@ -54,3 +61,8 @@ jobs:
title: Version Release
body: |
Bumping project version after release.
- name: Run the pull request checks
# Pull requests opened with GITHUB_TOKEN don't trigger workflows, but a workflow_dispatch sent with it does
run: gh workflow run pull-request.yml --ref version-release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
16 changes: 12 additions & 4 deletions github-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,16 @@ requireSnapshot() {
fi
}

removeSnapshots() {
sed -i 's/-SNAPSHOT//' pom.xml
setReleaseVersion() {
if [[ ! ${RELEASE_VERSION} =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Release version must look like 14.3.0: '${RELEASE_VERSION}'"
exit 1
fi
sed -i "0,/<version>.*<\/version>/s//<version>${RELEASE_VERSION}<\/version>/" pom.xml
local PREVIOUS_VERSION=${PREVIOUS_TAG#v}
sed -i -e "s/graphql-java-tools:${PREVIOUS_VERSION}'/graphql-java-tools:${RELEASE_VERSION}'/" \
-e "s/<version>${PREVIOUS_VERSION}<\/version>/<version>${RELEASE_VERSION}<\/version>/" README.md
grep -q "<version>${RELEASE_VERSION}</version>" README.md || echo "::warning::README.md still shows another version, update it manually"
}

commitRelease() {
Expand All @@ -27,7 +35,6 @@ publishTag() {
local APP_VERSION=$(getVersion)
git push origin "v${APP_VERSION}"
# Release tags aren't on master's first-parent history, so GitHub can't find the previous one on its own
local PREVIOUS_TAG=$(gh release view --json tagName --jq .tagName)
gh release create "v${APP_VERSION}" --verify-tag --draft --generate-notes --notes-start-tag "${PREVIOUS_TAG}" --title "v${APP_VERSION}" \
|| echo "::warning::Draft release for v${APP_VERSION} was not created, create it manually"
}
Expand Down Expand Up @@ -61,9 +68,10 @@ git config --global user.email "actions@github.com"
git config --global user.name "GitHub Actions"

requireSnapshot
PREVIOUS_TAG=$(gh release view --json tagName --jq .tagName)

echo "Deploying release to Maven Central"
removeSnapshots
setReleaseVersion

mvn --batch-mode -Prelease deploy

Expand Down
Loading