@@ -3,11 +3,6 @@ name: Deploy a branch
33on :
44 workflow_dispatch :
55 inputs :
6- dry-run :
7- description : " Dry run"
8- default : true
9- type : boolean
10-
116 deploy-to-staging :
127 description : " Deploy to staging"
138 default : true
2924 name : Build and deploy code
3025 runs-on : ubuntu-22.04
3126
32- # No concurrency groups, as we do not want to risk cancelling this job midway through a
33- # run and producing a tag without pushing to Maven Central at the same time.
34-
3527 permissions :
3628 contents : write
3729 id-token : write
38- pages : write
3930
4031 steps :
4132 - name : Checkout repository
@@ -59,75 +50,92 @@ jobs:
5950 shell : bash
6051 run : |-
6152 source ./scripts/common.sh
62-
63- info "Applying Git user configuration"
6453 run <<SCRIPT
6554 git config user.name '${{ github.actor }}'
6655 git config user.email '${{ github.actor }}@users.noreply.github.com'
6756 SCRIPT
6857
69- - name : Perform release to Maven Central
58+ - name : Determine groupId
7059 shell : bash
7160 run : |-
72- source ./scripts/common.sh
73-
74- info "Determining group ID..."
7561 group_id="$(./mvnw help:evaluate -q -DforceStdout -Dexpression="project.groupId")"
62+ echo "group_id=${group_id}" >> "${GITHUB_ENV}"
7663
77- info "Determining (root) artifact ID..."
64+ - name : Determine artifactId
65+ shell : bash
66+ run : |-
7867 artifact_id="$(./mvnw help:evaluate -q -DforceStdout -Dexpression="project.artifactId")"
68+ echo "artifact_id=${artifact_id}" >> "${GITHUB_ENV}"
7969
80- info "Determining release version to use..."
70+ - name : Determine final release version number
71+ shell : bash
72+ run : |-
8173 if [[ '${{ inputs.version }}' == "" ]]; then
8274 release_version="$(./mvnw -B help:evaluate -Dexpression=project.version -q -DforceStdout | sed 's/-SNAPSHOT//g')"
8375 else
8476 release_version='${{ inputs.version }}'
8577 fi
78+ echo "release_version=${release_version}" >> "${GITHUB_ENV}"
79+
80+ - name : Perform release to Staging
81+ id : maven-central-staging
82+ if : inputs.deploy-to-staging
83+ shell : bash
84+ run : |-
85+ source ./scripts/common.sh
8686
8787 info "Will release ${group_id}/${artifact_id}/${release_version} to Nexus staging"
8888
89- info "Preparing and performing the release"
9089 ensure-set OSSRH_USERNAME OSSRH_TOKEN GPG_PASSPHRASE
91-
92- if [ '${{ inputs.deploy-to-staging }}' == "true" ]; then
93- build_args=(
94- "-Dmaven.test.skip"
95- "-DskipTests"
96- "-Dlicense.skip=true"
97- "-Dcheckstyle.skip=true"
98- "-Preleases"
99- )
100-
101- run <<-SCRIPT
102- ./mvnw -B -e \
103- -Preleases \
104- -Darguments='${build_args[@]}' \
105- -DdryRun='${{ inputs.dry-run }} ' \
106- -Dpassword='${{ secrets.GITHUB_TOKEN }}' \
107- -DreleaseVersion='${release_version}' \
108- -DsignTag=false \
109- -Dtag='v${release_version}' \
110- release:prepare release:perform
90+ info "Preparing and performing the release"
91+
92+ build_args=(
93+ "-Dmaven.test.skip"
94+ "-DskipTests"
95+ "-Dlicense.skip=true"
96+ "-Dcheckstyle.skip=true"
97+ "-Preleases"
98+ )
99+
100+ run <<-SCRIPT
101+ ./mvnw -B -e \
102+ -Preleases \
103+ -Darguments='${build_args[@]}' \
104+ -DdryRun='false ' \
105+ -Dpassword='${{ secrets.GITHUB_TOKEN }}' \
106+ -DreleaseVersion='${release_version}' \
107+ -DsignTag=false \
108+ -Dtag='v${release_version}' \
109+ release:prepare release:perform
111110 SCRIPT
112111
113- success "Release has been promoted to Nexus Staging successfully"
114- fi
112+ success "Release has been promoted to Nexus Staging successfully"
113+ env :
114+ OSSRH_USERNAME : ${{ secrets.OSSRH_USERNAME }}
115+ OSSRH_TOKEN : ${{ secrets.OSSRH_TOKEN }}
116+ GPG_PASSPHRASE : ${{ secrets.GPG_PASSPHRASE }}
117+
118+ - name : Promote Nexus staging to releases repo
119+ id : maven-central-releases
120+ if : inputs.promote-to-release && !inputs.dry-run
121+ shell : bash
122+ run : |-
123+ source ./scripts/common.sh
115124
116- if [ "${{ inputs.promote-to-release }}" == "true" ] && [ "${{ inputs.dry-run }}" == "false" ]; then
117- info "Will now promote ${group_id}/${artifact_id}/${release_version} to Maven Central"
125+ ensure-set OSSRH_USERNAME OSSRH_TOKEN GPG_PASSPHRASE
126+ info "Will now promote ${group_id}/${artifact_id}/${release_version} to Maven Central"
118127
119- run <<-SCRIPT
120- ./scripts/close-nexus-repository.sh \
121- -u "${OSSRH_USERNAME}" \
122- -p "${OSSRH_TOKEN}" \
123- -g "${group_id}" \
124- -a "${artifact_id}" \
125- -v "${release_version}" \
126- -s "https://s01.oss.sonatype.org/"
128+ run <<-SCRIPT
129+ ./scripts/close-nexus-repository.sh \
130+ -u "${OSSRH_USERNAME}" \
131+ -p "${OSSRH_TOKEN}" \
132+ -g "${group_id}" \
133+ -a "${artifact_id}" \
134+ -v "${release_version}" \
135+ -s "https://s01.oss.sonatype.org/"
127136 SCRIPT
128137
129- success "Released ${group_id}/${artifact_id}/${release_version} to Maven Central successfully"
130- fi
138+ success "Released ${group_id}/${artifact_id}/${release_version} to Maven Central successfully"
131139 env :
132140 OSSRH_USERNAME : ${{ secrets.OSSRH_USERNAME }}
133141 OSSRH_TOKEN : ${{ secrets.OSSRH_TOKEN }}
0 commit comments