-
Notifications
You must be signed in to change notification settings - Fork 10
ci: github action for automated releasing #440
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
karel-rehor
wants to merge
108
commits into
InfluxCommunity:main
from
karel-rehor:ci/gh-action-maven-releasing
Closed
Changes from all commits
Commits
Show all changes
108 commits
Select commit
Hold shift + click to select a range
63527a3
ci: start maven-release.yml workflow
karel-rehor a7fb454
chore: remove branches tag on release trigger
karel-rehor 07c0179
chore: add here doc for generating release.properties
karel-rehor fc9e61f
chore: fix typo
karel-rehor f9e2f7b
chore: update pom.xml and deploy-settings.xml for fork.
karel-rehor e4924eb
chore: add simple volume check to workflow
karel-rehor e3c8b73
chore: add release command to model release step
karel-rehor ca363ca
chore: reintroduce verify step to maven0release.yml workflow
karel-rehor ef9469d
docs: start RELEASE.md
karel-rehor 1bb3896
docs: document gpg2 key generation in RELEASE.md.
karel-rehor f9695e4
chore: reintroduce checks in scripts/on-release.sh
karel-rehor 46bf3d1
docs: update temporary notes in CHANGELOG.md
karel-rehor e26af07
chore: fix file permissions for on-release.sh
karel-rehor bdcffe0
docs: temporary change to release date - for testing workflow.
karel-rehor e0a9412
docs: temporary update toe README.md to test workflow.
karel-rehor 4e52241
chore: set correct scm version an update RELEASE.md
karel-rehor 8dff66d
chore: add scm/tag value check to on-release.sh
karel-rehor 1eee676
chore: fix dropped variable in on-release.sh
karel-rehor dabbd1f
chore: temporarily change scm tag to test workflow failure.
karel-rehor 93a7e9d
chore: revert scm tag in pom.xml after workflow test proven correct.
karel-rehor fdce5bc
chore: start workflow step Prepare next cycle.
karel-rehor d07c44f
chore: get correct TAG_NAME envar in workflow script.
karel-rehor 8b9409a
chore: set next release cycle branch
karel-rehor 933d9d5
chore: fix broken variable string in script.
karel-rehor 602d2cb
chore: temporarily add debugging checks to workflow script.
karel-rehor c8b67a6
chore: add automatic update to CHANGELOG.md in workflow.
karel-rehor 29aff53
chore: use correct envar in workflow script.
karel-rehor d4dc622
chore: fix formatting of next release CHANGELOG.md header
karel-rehor 8098ee9
chore: setup automated git commands for next release cycle.
karel-rehor 6c17568
chore: setup github identity in release workflow prepare next cycle.
karel-rehor 4f69b60
chore: fix push to origin in workstream Prepare next cycle.
karel-rehor 29d4bae
chore: fix origin repository in workflow Prepare next release cycle.
karel-rehor 6410172
chore: setup automatic PR for new release cycle.
karel-rehor ff9cb5a
chore: update permissions to allow creation of PR.
karel-rehor b0dbac5
chore: remove automatic PR merge command - requires permission change…
karel-rehor ee489d0
chore: add site documentation update step. Update RELEASE.md
karel-rehor 9bc7007
chore: add checks and updates to examples/pom.xml
karel-rehor 1c8ae70
chore: temporarily change examples dependency version to verify workf…
karel-rehor d7f69a0
chore: fix typo
karel-rehor 796fccd
chore: tidy maven-release.yml
karel-rehor f70db2a
chore: add check for remote next release branch.
karel-rehor bea3059
docs: updated and proofed RELEASE.md
karel-rehor dafc3f3
chore: clarify error message.
karel-rehor 3886aab
docs: add Maven Central step to releasing instructions.
karel-rehor b799c9a
chore: remove debug messages from on-release.sh
karel-rehor 27e9568
chore: remove debug messages from maven-release.yml
karel-rehor 0e21e5c
Merge branch 'InfluxCommunity:main' into ci/gh-action-maven-releasing
karel-rehor 02183e1
chore: troubleshoot document releasing step
karel-rehor 42877b5
chore: troubleshoot site publishing issue 02
karel-rehor c90cbae
chore: troubleshoot site publishing - set to global.
karel-rehor 12464a8
chore: revert pubScmUrl - troubleshoot site publishing step.
karel-rehor aa5aaac
chore: troubleshoot sit publishing 03
karel-rehor d21ffce
chore: modify pubScmUrl to troubleshoot site publishing
karel-rehor bf81205
chore: troubleshoot site publishing 05
karel-rehor d7db961
chore: revert troubleshoot changes
karel-rehor 34ec4c8
chore: troubleshoot site publishing 06
karel-rehor 49d8666
chore: troubleshoot publish site documents.
karel-rehor bd772c6
chore: fix typo
karel-rehor 13bc63e
chore: troubleshoot site document releasing 07
karel-rehor ee077b1
chore: troubleshoot site documentation 08
karel-rehor 7eac1e3
chore: troubleshoot publish sit documentation 09
karel-rehor 0ceeca9
chore: troubleshoot publish sit documentation 10
karel-rehor 0d9c017
chore: troubleshoot publish sit documentation 11
karel-rehor 823c132
chore: troubleshoot publish sit documentation 12
karel-rehor d3c750e
chore: troubleshoot publish sit documentation 13
karel-rehor 396decb
chore: troubleshoot publish sit documentation 14
karel-rehor 702a610
chore: troubleshoot publish sit documentation 15
karel-rehor 727eb19
chore: troubleshoot publish sit documentation 16
karel-rehor 28cecc2
chore: troubleshoot publish sit documentation 17
karel-rehor 260418a
chore: troubleshoot publish sit documentation 18
karel-rehor 992844f
chore: remove debug commands from Publish documentation step.
karel-rehor e542768
chore: experim - try automatic PR creation.
karel-rehor 73dac4a
chore: experim - try to create new PR 02
karel-rehor 4c0739a
chore: switch off automatic PR creation, requires special permissions.
karel-rehor e8e7b75
chore: reactivate branch controls for prerelease.
karel-rehor 52c96b6
chore: add env checks for matching scm values.
karel-rehor d54457c
chore: fix path in script.
karel-rehor 8f11019
chore: remove debug of script ENV.
karel-rehor 9059208
chore: remove commented nodes from pom.xml
karel-rehor 1d4a4ab
docs: update RELEASE.md to match current workflow.
karel-rehor cbefea3
chore: remove unnecessary commands from workflow.
karel-rehor ddeddf3
chore: prepare automated releasing branch for PR to upstream.
karel-rehor 7c817c4
chore: remove experimental permissions from release workflow.
karel-rehor 9130d11
docs: update CHANGELOG.md
karel-rehor 3d958a8
docs: lint fixes for RELEASE.md
karel-rehor 8afc194
docs: fix linting issues in RELEASE.md
karel-rehor 2b58fee
docs: fixing lint issues in RELEASE.md 02
karel-rehor 93ab125
docs: fix typos in RELEASE.md
karel-rehor 620b863
chore: fixing lint issues in on-release.sh
karel-rehor 21de1d6
chore: fix lint issues in maven-release.yml
karel-rehor 4242886
chore: fix linter issue in maven-release.yml
karel-rehor 199c93d
chore: revise pom version values to match upstream HEAD.
karel-rehor 8325ce4
docs: anonymize commands in RELEASE.md
karel-rehor fb989d9
chore: fix typo in on-releas.sh, add reminder to check RC_OR_BETA tag…
karel-rehor 4d90a18
chore: fix flaws in workflow and bash scripts.
karel-rehor 335aac5
chore: use more meaningful user.email in workflow.
karel-rehor f7dd26c
chore: use current shell when calling on-release.sh in workflow
karel-rehor 071979c
Merge branch 'InfluxCommunity:main' into ci/gh-action-maven-releasing
karel-rehor b4f8422
chore: fix RC or BETA release tag checks.
karel-rehor c9af311
chore: update trigger, fix snapshot credentials, verify workfow envars.
karel-rehor d5d68d8
chore: remove TODO and set RC_OR_BETA envar
karel-rehor 8c12cd0
chore: fix typos add TODOs for fixes in on-release.sh
karel-rehor 2a25e18
Merge branch 'InfluxCommunity:main' into ci/gh-action-maven-releasing
karel-rehor 714d229
chore: improve checks in on-release.sh
karel-rehor c02677c
chore: better control sequencing, better checks in workflow.
karel-rehor 8537d04
chore: fine tune release workflow and script.
karel-rehor a36fec1
chore: remove snapshot checks, revert workflow check for next working…
karel-rehor 8084ad5
chore: fine tune behavior for patch releases.
karel-rehor File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,248 @@ | ||
| name: Maven Releasing | ||
|
|
||
| on: | ||
|
|
||
| release: | ||
| types: [published] | ||
|
|
||
| jobs: | ||
| release: | ||
| permissions: | ||
| contents: write # may want to update version | ||
| runs-on: ubuntu-latest | ||
| env: | ||
| SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} | ||
| SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} | ||
| MAVEN_SETTINGS_EXPERIM: ${{ vars.MAVEN_SETTINGS_FILE }} | ||
| GPG_PASSPHRASE_PRELIM: ${{ secrets.GPG_PASSPHRASE }} | ||
| RELEASE_TAG_NAME: ${{ github.event.release.tag_name }} | ||
| IS_PRERELEASE: ${{ github.event.release.prerelease }} | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| GITHUB_REPO: ${{ github.repository }} | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v6 | ||
| - name: Setup JDK 21 | ||
| uses: actions/setup-java@v5 | ||
| with: | ||
| java-version: '21' | ||
| distribution: 'temurin' | ||
| cache: maven | ||
| gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} | ||
| - name: Add dependencies | ||
| run: | | ||
| sudo apt-get update | ||
| sudo apt-get -y install libxml2-utils | ||
| - name: Verify Env | ||
| run: | | ||
| if [[ -z "${{ secrets.GPG_PRIVATE_KEY }}" ]] | ||
| then | ||
| echo "ERROR GPG_PRIVATE_KEY is missing." | ||
| exit 1 | ||
| fi | ||
| # ensure scm properties match current project - don't want to modify other repository inadvertently | ||
| POM_SITE_URL=$(xmllint --xpath "//*[local-name()='distributionManagement']/*[local-name()='site']/*[local-name()='url']/text()" ./pom.xml) | ||
| POM_SCM_CONNECTION=$(xmllint --xpath "//*[local-name()='scm']/*[local-name()='connection']/text()" ./pom.xml) | ||
| POM_SCM_DEVELOPER_CONNECTION=$(xmllint --xpath "//*[local-name()='scm']/*[local-name()='developerConnection']/text()" ./pom.xml) | ||
|
|
||
| if [[ ! "${POM_SITE_URL}" != "scm:git:https://github.com/${GITHUB_REPOSITORY}" ]] | ||
| then | ||
| echo "POM_SITE_URL ${POM_SITE_URL} does not match GITHUB_REPOSITORY ${GITHUB_REPOSITORY}" | ||
| exit 1 | ||
| else | ||
| echo "POM_SITE_URL OK ✓." | ||
| fi | ||
|
|
||
| if [[ ! "${POM_SCM_CONNECTION}" =~ .*${GITHUB_REPOSITORY}\.git$ ]] | ||
| then | ||
| echo "POM_SCM_CONNECTION ${POM_SCM_CONNECTION} does not match GITHUB_REPOSITORY ${GITHUB_REPOSITORY}" | ||
| exit 1 | ||
| else | ||
| echo "POM_SCM_CONNECTION OK ✓." | ||
| fi | ||
|
|
||
| if [[ ! "${POM_SCM_DEVELOPER_CONNECTION}" =~ .*${GITHUB_REPOSITORY}\.git$ ]] | ||
| then | ||
| echo "POM_SCM_DEVELOPER_CONNECTION ${POM_SCM_DEVELOPER_CONNECTION} does not match GITHUB_REPOSITORY ${GITHUB_REPOSITORY}" | ||
| exit 1 | ||
| else | ||
| echo "POM_SCM_DEVELOPER_CONNECTION OK ✓." | ||
| fi | ||
|
|
||
| if [[ -n "$SONATYPE_USERNAME" ]] | ||
| then | ||
| echo "have SONATYPE_USERNAME" | ||
| else | ||
| echo "Release requires SONATYPE_USERNAME, which was not found. exiting" | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [[ -n "$SONATYPE_PASSWORD" ]] | ||
| then | ||
| echo "have SONATYPE_PASSWORD" | ||
| else | ||
| echo "Release requires SONATYPE_PASSWORD, which was not found. exiting" | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [[ -n "$GPG_PASSPHRASE_PRELIM" ]] | ||
| then | ||
| echo "have GPG_PASSPHRASE_PRELIM" | ||
| else | ||
| echo "Release requires GPG_PASSPHRASE, which was not found. exiting" | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [[ "$GPG_PASSPHRASE_PRELIM" == "EMPTY" ]] | ||
| then | ||
| echo "GPG_PASSPHRASE empty requested" | ||
| export GPG_PASSPHRASE="" | ||
| else | ||
| export GPG_PASSPHRASE="$GPG_PASSPHRASE_PRELIM" | ||
| fi | ||
|
|
||
| echo "GPG_PASSPHRASE=${GPG_PASSPHRASE}" >> "$GITHUB_ENV" | ||
|
|
||
| # Verify GPG2 environment | ||
| if ! command -v gpg2 &> /dev/null | ||
| then | ||
| echo "Failed to locate gpg2 on this host. GPG2 is required to continue." | ||
| exit 1 | ||
| fi | ||
|
|
||
| gpg2 --version | ||
| GPG_EXECUTABLE=$(command -v gpg2) | ||
| export GPG_EXECUTABLE | ||
| echo "GPG_EXECUTABLE=${GPG_EXECUTABLE}" >> "$GITHUB_ENV" | ||
|
|
||
| # Verify tag and next version | ||
| if ! echo "${RELEASE_TAG_NAME}" | grep -Ei '^v[0-9]+\.[0-9]+\.[0-9]+(-(rc|beta)[0-9]*)?$' | ||
| then | ||
| echo "RELEASE_TAG_NAME ${RELEASE_TAG_NAME} does not match expected pattern, e.g. (v1.9.0). Exiting." | ||
| exit 1 | ||
| fi | ||
| VERSION_CLEAN="${RELEASE_TAG_NAME:1}" | ||
| # shellcheck disable=SC2206 | ||
| PARTS=(${VERSION_CLEAN//./ }) | ||
| # TODO Check if PARTS[2] starts with 0 or [1-9] if not 0 then this is hot release and should not trigger publishing | ||
| if ! echo "${PARTS[2]}" | grep -q "^0.*" | ||
| then | ||
| echo "Detected hot fix release ${RELEASE_TAG_NAME}" | ||
| echo "IS_HOT_FIX=true" >> "${GITHUB_ENV}" | ||
|
karel-rehor marked this conversation as resolved.
|
||
| fi | ||
| NEW_MINOR=$((PARTS[1]+1)) | ||
| NEXT_RELEASE="${PARTS[0]}.${NEW_MINOR}.0" | ||
| echo "NEXT_RELEASE=${NEXT_RELEASE}" >> "${GITHUB_ENV}" | ||
| NEXT_RELEASE_BRANCH="ci/next-cycle-${NEXT_RELEASE}" | ||
| git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" | ||
| git config user.name "${GITHUB_ACTOR}" | ||
|
|
||
| if [[ "${IS_PRERELEASE}" != "true" && "${RELEASE_TAG_NAME,,}" =~ ^v[0-9]+\.[0-9]+\.0$ ]] | ||
| then | ||
| BRANCH_CHECK=$(git ls-remote --heads origin "refs/heads/${NEXT_RELEASE_BRANCH}") | ||
| if [ -n "${BRANCH_CHECK}" ] | ||
| then | ||
| echo "branch ${NEXT_RELEASE_BRANCH} already exists in project. Cannot recreate it automatically." | ||
| echo "If you wish to use this automatically created branch, please delete the existing branch and start the release again" | ||
| exit 1 | ||
| fi | ||
| else | ||
| echo "Skipping next release cycle branch check because this is either a pre-release or a patch fix." | ||
| fi | ||
|
|
||
| echo "NEXT_RELEASE_BRANCH=${NEXT_RELEASE_BRANCH}" >> "$GITHUB_ENV" | ||
|
|
||
| - name: Script | ||
| run: | | ||
| . ./scripts/on-release.sh | ||
| echo "RC_OR_BETA=${RC_OR_BETA}" >> "$GITHUB_ENV" | ||
| - name: Release | ||
| run: | | ||
| if [[ "${IS_PRERELEASE}" == "true" ]]; then | ||
| echo "This is a pre release and will not be deployed to Maven Central." | ||
| exit 0 | ||
| fi | ||
| if [[ "${RC_OR_BETA}" == "true" ]] | ||
| then | ||
| echo "This is an RC or BETA release and will not be deployed to Maven Central." | ||
| exit 0 | ||
| fi | ||
| cat << EOF > release.properties | ||
| scm.url=scm\:git\:https\://github.com/${GITHUB_REPOSITORY}.git | ||
| scm.tag=${RELEASE_TAG_NAME} | ||
| EOF | ||
| cat release.properties | ||
| mvn release:perform \ | ||
| -Dgoals=deploy \ | ||
| -s ./deploy-settings.xml \ | ||
| -Darguments="-DskipTests -DskipITs -DperformRelease=true" | ||
| - name: Prepare next cycle | ||
| run: | | ||
| if [[ "${IS_PRERELEASE}" == "true" ]]; then | ||
| echo "This is a prerelease so the next release cycle will not be prepared." | ||
| exit 0 | ||
| fi | ||
| if [[ "${RC_OR_BETA}" == "true" ]] | ||
| then | ||
| echo "This is an RC or BETA release so next release cycle will not be prepared." | ||
| exit 0 | ||
| fi | ||
| if [[ "${IS_HOT_FIX}" == "true" ]] | ||
| then | ||
| echo "This is a hot fix release ${RELEASE_TAG_NAME}, so next release cycle will not be prepared." | ||
| exit 0 | ||
| fi | ||
|
|
||
| echo "Preparing next release cycle" | ||
|
|
||
| git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" | ||
| git config user.name "${GITHUB_ACTOR}" | ||
| echo "checking out next release branch ${NEXT_RELEASE_BRANCH}" | ||
| git checkout -b "${NEXT_RELEASE_BRANCH}" | ||
| mvn versions:set-scm-tag -DnewTag="HEAD" | ||
| mvn versions:set -DnextSnapshot=true -DnextSnapshotIndexToIncrement=1 | ||
| sed -i "1s/^/## ${NEXT_RELEASE:1} [unreleased]\n\n/" CHANGELOG.md | ||
| sed -i -e "s/<version>${RELEASE_TAG_NAME:1}<\/version>/<version>${NEXT_RELEASE:1}-SNAPSHOT<\/version>/" examples/pom.xml | ||
| git add pom.xml examples/pom.xml CHANGELOG.md | ||
| git commit -m "ci: setting up release cycle ${NEXT_RELEASE:1}" | ||
| git push --set-upstream origin "${NEXT_RELEASE_BRANCH}" | ||
| # The following requires special permissions on the organizational and project level to work. Switching off for now. | ||
| # gh pr create -B main -H ${NEXT_RELEASE_BRANCH} --title "Merge ${NEXT_RELEASE_BRANCH} into main" --body 'Created by Github action' | ||
| # The alternative is to create the PR by hand | ||
| echo "The branch ${NEXT_RELEASE_BRANCH} has been created. You can create and merge a PR manually from it to start the next release cycle." | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| - name: Publish documentation | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| run: | | ||
| if [[ "${IS_PRERELEASE}" == "true" ]]; then | ||
| echo "This is a pre release, so site documentation will not be updated to Github pages." | ||
| exit 0 | ||
| fi | ||
| if [[ "${RC_OR_BETA}" == "true" ]] | ||
| then | ||
| echo "This is an RC or BETA release, so site documentation will not be updated to Github pages." | ||
| exit 0 | ||
| fi | ||
| if [[ "${IS_HOT_FIX}" == "true" ]] | ||
| then | ||
| echo "This is a hot fix release ${RELEASE_TAG_NAME}, so site documentation will not be updated to Github pages." | ||
| exit 0 | ||
| fi | ||
| cat << EOF > scm-settings.xml | ||
| <settings> | ||
| <servers> | ||
| <server> | ||
| <id>github</id> | ||
| <username>x-access-token</username> | ||
| <password>${GITHUB_TOKEN}</password> | ||
| </server> | ||
| </servers> | ||
| </settings> | ||
| EOF | ||
| git config --global user.email "${GITHUB_TRIGGERING_ACTOR}@noreply.github.com" | ||
| git config --global user.name "Github Action" | ||
| git checkout "${RELEASE_TAG_NAME}" | ||
| mvn clean site site:stage -DskipTests | ||
| mvn -s scm-settings.xml --batch-mode scm-publish:publish-scm -Dscmpublish.serverId=github | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.