-
Notifications
You must be signed in to change notification settings - Fork 18
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
Add github action to release maven artifacts #29
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
name: Publish Release | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
prepare_release: | ||
description: 'Prepare release' | ||
type: boolean | ||
required: false | ||
default: true | ||
publish_artifacts: | ||
description: 'Publish maven artifacts' | ||
type: boolean | ||
required: false | ||
default: true | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
environment: release | ||
strategy: | ||
fail-fast: true | ||
permissions: | ||
contents: write | ||
packages: write | ||
|
||
steps: | ||
- name: Check branch | ||
if: ${{ github.ref != 'refs/heads/master' }} | ||
run: echo "Invalid branch. This action can only be run on the master branch." && exit 1 | ||
|
||
- uses: actions/checkout@v4 | ||
with: | ||
token: ${{ secrets.PRESTODB_CI_TOKEN }} | ||
ref: master | ||
show-progress: false | ||
fetch-depth: 5 | ||
fetch-tags: true | ||
|
||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
overwrite-settings: true | ||
server-id: ossrh | ||
server-username: NEXUS_USERNAME | ||
server-password: NEXUS_PASSWORD | ||
gpg-private-key: ${{ secrets.GPG_SECRET }} | ||
Comment on lines
+46
to
+49
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. generate settings.xml |
||
|
||
- name: Setup git | ||
run: | | ||
git config --global --add safe.directory ${{github.workspace}} | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "prestodb-ci" | ||
git config --global alias.ls 'log --pretty=format:"%cd %h %ce: %s" --date=short --no-merges' | ||
git config pull.rebase false | ||
git ls -3 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. list latest 3 commits |
||
|
||
- name: Get current version | ||
run: | | ||
CURRENT_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) | ||
echo "CURRENT_VERSION=${CURRENT_VERSION}" | ||
echo "CURRENT_VERSION=${CURRENT_VERSION}" >> $GITHUB_ENV | ||
|
||
- name: Prepare release | ||
if: ${{ inputs.prepare_release }} | ||
run: | | ||
mvn release:prepare -B -DskipTests \ | ||
-DautoVersionSubmodules=true \ | ||
-DgenerateBackupPoms=false | ||
echo "RELEASE_VERSION=$(grep scm.tag= release.properties | cut -d'=' -f2)" >> $GITHUB_ENV | ||
git ls -5 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. list lastest 3 commits plus 2 commits by |
||
|
||
- name: Set release version | ||
if: ${{ !inputs.prepare_release }} | ||
env: | ||
CURRENT_VERSION: ${{ env.CURRENT_VERSION }} | ||
run: | | ||
VERSION_WITHOUT_SNAPSHOT=${CURRENT_VERSION%-SNAPSHOT} | ||
VERSION=${VERSION_WITHOUT_SNAPSHOT%.*} | ||
RELEASE_VERSION=$((VERSION - 1)) | ||
echo "RELEASE_VERSION=${RELEASE_VERSION}" | ||
echo "RELEASE_VERSION=${RELEASE_VERSION}" >> $GITHUB_ENV | ||
Comment on lines
+80
to
+84
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If unchecked prepare_release, will use last release as the RELEASE_VERSION |
||
|
||
- name: Set up GPG key | ||
if: ${{ inputs.publish_artifacts }} | ||
env: | ||
GPG_TTY: $(tty) | ||
GPG_PASSPHRASE: "${{ secrets.GPG_PASSPHRASE }}" | ||
GPG_KEY_FILE: /tmp/gpg-key.txt | ||
run: | | ||
echo "${{ secrets.GPG_SECRET }}" > ${{ env.GPG_KEY_FILE }} | ||
chmod 600 ${{ env.GPG_KEY_FILE }} | ||
gpg --import --batch ${{ env.GPG_KEY_FILE }} | ||
gpg --batch --yes --pinentry-mode loopback --passphrase "${{ secrets.GPG_PASSPHRASE }}" --sign ${{ env.GPG_KEY_FILE }} | ||
|
||
- name: Publish maven artifacts | ||
if: ${{ inputs.publish_artifacts }} | ||
env: | ||
NEXUS_USERNAME: "${{ secrets.NEXUS_USERNAME }}" | ||
NEXUS_PASSWORD: "${{ secrets.NEXUS_PASSWORD }}" | ||
GPG_PASSPHRASE: "${{ secrets.GPG_PASSPHRASE }}" | ||
RELEASE_VERSION: "${{ env.RELEASE_VERSION }}" | ||
run: | | ||
echo "RELEASE_VERSION=${RELEASE_VERSION}" | ||
git checkout "${RELEASE_VERSION}" | ||
git ls -4 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. list latest 3 commts plus a maven commit |
||
mvn -V -B -U -e -T2C deploy \ | ||
-DautoReleaseAfterClose=true \ | ||
-Dgpg.passphrase="${GPG_PASSPHRASE}" \ | ||
-DkeepStagingRepositoryOnCloseRuleFailure=true \ | ||
-DkeepStagingRepositoryOnFailure=true \ | ||
-DskipTests \ | ||
-Poss-release \ | ||
-Pdeploy-to-ossrh \ | ||
-DstagingProgressTimeoutMinutes=10 | ||
|
||
- name: Push changes and tags | ||
if: ${{ inputs.prepare_release }} | ||
run: | | ||
git checkout master | ||
git ls -5 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. list the latest 3 commits plus 2 maven commits |
||
git push origin master --tags |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
keep 5 commits in history