Skip to content

Commit 8b97e3f

Browse files
committed
Add release action
1 parent bfe642e commit 8b97e3f

File tree

1 file changed

+127
-0
lines changed

1 file changed

+127
-0
lines changed

.github/workflows/release.yml

+127
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
name: Publish Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
prepare_release:
7+
description: 'Prepare release'
8+
type: boolean
9+
required: false
10+
default: true
11+
publish_artifacts:
12+
description: 'Publish maven artifacts'
13+
type: boolean
14+
required: false
15+
default: true
16+
17+
env:
18+
MAVEN_OPTS: "-Xmx1024m"
19+
20+
jobs:
21+
release:
22+
runs-on: ubuntu-latest
23+
environment: release
24+
strategy:
25+
fail-fast: true
26+
permissions:
27+
contents: write
28+
packages: write
29+
30+
steps:
31+
- name: Check branch
32+
if: ${{ github.ref != 'refs/heads/master' }}
33+
run: echo "Invalid branch. This action can only be run on the master branch." && exit 1
34+
35+
- uses: actions/checkout@v4
36+
with:
37+
token: ${{ secrets.PRESTODB_CI_TOKEN }}
38+
ref: master
39+
show-progress: false
40+
fetch-depth: 5
41+
fetch-tags: true
42+
43+
- name: Set up JDK 8
44+
uses: actions/setup-java@v4
45+
with:
46+
java-version: '8'
47+
distribution: 'temurin'
48+
overwrite-settings: true
49+
server-id: ossrh
50+
server-username: NEXUS_USERNAME
51+
server-password: NEXUS_PASSWORD
52+
gpg-private-key: ${{ secrets.GPG_SECRET }}
53+
54+
- name: Setup git
55+
run: |
56+
git config --global --add safe.directory ${{github.workspace}}
57+
git config --global user.email "[email protected]"
58+
git config --global user.name "prestodb-ci"
59+
git config --global alias.ls 'log --pretty=format:"%cd %h %ce: %s" --date=short --no-merges'
60+
git config pull.rebase false
61+
git ls -3
62+
63+
- name: Get current version
64+
run: |
65+
CURRENT_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
66+
echo "CURRENT_VERSION=${CURRENT_VERSION}"
67+
echo "CURRENT_VERSION=${CURRENT_VERSION}" >> $GITHUB_ENV
68+
69+
- name: Prepare release
70+
if: ${{ inputs.prepare_release }}
71+
run: |
72+
mvn release:prepare -B -DskipTests \
73+
-DautoVersionSubmodules=true \
74+
-DgenerateBackupPoms=false
75+
echo "RELEASE_VERSION=$(grep scm.tag= release.properties | cut -d'=' -f2)" >> $GITHUB_ENV
76+
git ls -5
77+
78+
- name: Set release version
79+
if: ${{ !inputs.prepare_release }}
80+
env:
81+
CURRENT_VERSION: ${{ env.CURRENT_VERSION }}
82+
run: |
83+
VERSION_WITHOUT_SNAPSHOT=${CURRENT_VERSION%-SNAPSHOT}
84+
VERSION=${VERSION_WITHOUT_SNAPSHOT%.*}
85+
RELEASE_VERSION=$((VERSION - 1))
86+
echo "RELEASE_VERSION=${RELEASE_VERSION}"
87+
echo "RELEASE_VERSION=${RELEASE_VERSION}" >> $GITHUB_ENV
88+
89+
- name: Set up GPG key
90+
if: ${{ inputs.publish_artifacts }}
91+
env:
92+
GPG_TTY: $(tty)
93+
GPG_PASSPHRASE: "${{ secrets.GPG_PASSPHRASE }}"
94+
GPG_KEY_FILE: /tmp/gpg-key.txt
95+
run: |
96+
echo "${{ secrets.GPG_SECRET }}" > ${{ env.GPG_KEY_FILE }}
97+
chmod 600 ${{ env.GPG_KEY_FILE }}
98+
gpg --import --batch ${{ env.GPG_KEY_FILE }}
99+
gpg --batch --yes --pinentry-mode loopback --passphrase "${{ secrets.GPG_PASSPHRASE }}" --sign ${{ env.GPG_KEY_FILE }}
100+
101+
- name: Publish maven artifacts
102+
if: ${{ inputs.publish_artifacts }}
103+
env:
104+
NEXUS_USERNAME: "${{ secrets.NEXUS_USERNAME }}"
105+
NEXUS_PASSWORD: "${{ secrets.NEXUS_PASSWORD }}"
106+
GPG_PASSPHRASE: "${{ secrets.GPG_PASSPHRASE }}"
107+
RELEASE_VERSION: "${{ env.RELEASE_VERSION }}"
108+
run: |
109+
echo "RELEASE_VERSION=${RELEASE_VERSION}"
110+
git checkout "${RELEASE_VERSION}"
111+
git ls -4
112+
mvn -V -B -U -e -T2C deploy \
113+
-DautoReleaseAfterClose=true \
114+
-Dgpg.passphrase="${GPG_PASSPHRASE}" \
115+
-DkeepStagingRepositoryOnCloseRuleFailure=true \
116+
-DkeepStagingRepositoryOnFailure=true \
117+
-DskipTests \
118+
-Poss-release \
119+
-Pdeploy-to-ossrh \
120+
-DstagingProgressTimeoutMinutes=10
121+
122+
- name: Push changes and tags
123+
if: ${{ inputs.prepare_release }}
124+
run: |
125+
git checkout master
126+
git ls -5
127+
git push origin master --tags

0 commit comments

Comments
 (0)