Skip to content

Commit 2e329e7

Browse files
committed
Add release action
1 parent cb219db commit 2e329e7

File tree

2 files changed

+107
-8
lines changed

2 files changed

+107
-8
lines changed

.github/workflows/release.yml

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: Publish release
2+
3+
on:
4+
workflow_dispatch:
5+
6+
env:
7+
JAVA_VERSION: ${{ vars.JAVA_VERSION }}
8+
JAVA_DISTRIBUTION: ${{ vars.JAVA_DISTRIBUTION }}
9+
MAVEN_OPTS: ${{ vars.MAVEN_OPTS }}
10+
GPG_KEY_FILE: /tmp/gpg-key.txt
11+
12+
jobs:
13+
publish-release:
14+
runs-on: ubuntu-latest
15+
environment: release
16+
strategy:
17+
fail-fast: true
18+
permissions:
19+
contents: write
20+
packages: write
21+
22+
steps:
23+
- name: Check branch
24+
if: ${{ github.ref != 'refs/heads/master' }}
25+
run: echo "Invalid branch. This action can only be run on the master branch." && exit 1
26+
27+
- name: Checkout source
28+
uses: actions/checkout@v4
29+
with:
30+
token: ${{ secrets.PRESTODB_CI_TOKEN }}
31+
show-progress: false
32+
fetch-depth: 0
33+
ref: master
34+
35+
- name: Set up JDK ${{ env.JAVA_DISTRIBUTION }}/${{ env.JAVA_VERSION }}
36+
uses: actions/setup-java@v4
37+
with:
38+
java-version: ${{ env.JAVA_VERSION }}
39+
distribution: ${{ env.JAVA_DISTRIBUTION }}
40+
overwrite-settings: true
41+
server-id: ossrh
42+
server-username: NEXUS_USERNAME
43+
server-password: NEXUS_PASSWORD
44+
gpg-private-key: ${{ secrets.GPG_SECRET }}
45+
46+
- name: Set up git
47+
run: |
48+
git config --global --add safe.directory ${{github.workspace}}
49+
git config --global user.email "[email protected]"
50+
git config --global user.name "prestodb-ci"
51+
git config --global alias.ls 'log --pretty=format:"%cd %h %ce: %s" --date=short --no-merges'
52+
git config pull.rebase false
53+
54+
- name: Get release version
55+
id: get-version
56+
run: |
57+
RELEASE_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout | tail -n 1 | sed 's/-SNAPSHOT//')
58+
echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV
59+
echo "RELEASE_VERSION=$RELEASE_VERSION"
60+
echo "In case cut release failed, please delete the tag ${RELEASE_VERSION} manually"
61+
62+
- name: Prepare release
63+
run: |
64+
git reset --hard
65+
mvn release:prepare -DreleaseVersion=${{ env.RELEASE_VERSION }}
66+
grep -m 1 "<version>" pom.xml
67+
git ls -5
68+
69+
- name: Set up GPG key
70+
env:
71+
GPG_TTY: $(tty)
72+
run: |
73+
echo "${{ secrets.GPG_SECRET }}" > ${{ env.GPG_KEY_FILE }}
74+
chmod 600 ${{ env.GPG_KEY_FILE }}
75+
gpg --import --batch ${{ env.GPG_KEY_FILE }}
76+
gpg --batch --yes --pinentry-mode loopback --passphrase "${{ secrets.GPG_PASSPHRASE }}" --sign ${{ env.GPG_KEY_FILE }}
77+
78+
- name: Publish release
79+
env:
80+
NEXUS_USERNAME: "${{ secrets.NEXUS_USERNAME }}"
81+
NEXUS_PASSWORD: "${{ secrets.NEXUS_PASSWORD }}"
82+
GPG_PASSPHRASE: "${{ secrets.GPG_PASSPHRASE }}"
83+
run: |
84+
git checkout ${{ env.RELEASE_VERSION }}
85+
git ls -5
86+
cat ~/.m2/settings.xml
87+
mvn -V -B -U -e -T2C deploy -Poss-release \
88+
-DautoReleaseAfterClose=true \
89+
-DkeepStagingRepositoryOnCloseRuleFailure=true \
90+
-DkeepStagingRepositoryOnFailure=true \
91+
-DstagingProgressTimeoutMinutes=10
92+
93+
- name: Push changes and tags
94+
run: |
95+
git checkout master
96+
git ls -5
97+
git push origin master --tags

pom.xml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.facebook.airlift</groupId>
77
<artifactId>airbase</artifactId>
8-
<version>105</version>
8+
<version>107</version>
99
</parent>
1010

1111
<groupId>com.facebook.presto.hadoop</groupId>
@@ -709,13 +709,15 @@
709709
</plugin>
710710

711711
<plugin>
712-
<groupId>org.sonatype.plugins</groupId>
713-
<artifactId>nexus-staging-maven-plugin</artifactId>
714-
<version>${dep.nexus-staging-plugin.version}</version>
712+
<groupId>org.sonatype.central</groupId>
713+
<artifactId>central-publishing-maven-plugin</artifactId>
714+
<version>${dep.central-publishing.version}</version>
715715
<extensions>true</extensions>
716716
<configuration>
717-
<serverId>ossrh</serverId>
718-
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
717+
<deploymentName>hadoop-apache2</deploymentName>
718+
<publishingServerId>ossrh</publishingServerId>
719+
<autoPublish>true</autoPublish>
720+
<waitUntil>validated</waitUntil>
719721
</configuration>
720722
</plugin>
721723
</plugins>
@@ -727,8 +729,8 @@
727729
<build>
728730
<plugins>
729731
<plugin>
730-
<groupId>org.sonatype.plugins</groupId>
731-
<artifactId>nexus-staging-maven-plugin</artifactId>
732+
<groupId>org.sonatype.central</groupId>
733+
<artifactId>central-publishing-maven-plugin</artifactId>
732734
</plugin>
733735
</plugins>
734736
</build>

0 commit comments

Comments
 (0)