Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 43 additions & 15 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,29 @@ on:

workflow_dispatch:
inputs:
snapshot:
description: 'Deploy SNAPSHOT'
release:
description: 'Release final version to Maven Central (strips -SNAPSHOT, tags, then bumps to the next -SNAPSHOT)'
type: boolean
default: false

permissions:
contents: read
contents: write

# Never let a push-triggered SNAPSHOT deploy race a manual release on the same branch.
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false

jobs:

deploy:
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
# Skip the automated commits the release plugin pushes back to main.
if: github.event_name == 'workflow_dispatch' || !startsWith(github.event.head_commit.message, '[maven-release-plugin]')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0

- uses: actions/setup-java@v5
with:
Expand All @@ -31,14 +39,11 @@ jobs:
- name: Grant Permission
run: chmod +x ./mvnw

- name: Validate SNAPSHOT version
if: inputs.snapshot == true
- name: Configure Git User
if: inputs.release == true
run: |
VERSION=$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout)
if [[ "$VERSION" != *-SNAPSHOT ]]; then
echo "::error::Version $VERSION is not a SNAPSHOT version"
exit 1
fi
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"

- name: Remove old Maven Settings
run: rm -f /home/runner/.m2/settings.xml
Expand All @@ -59,8 +64,31 @@ jobs:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}

- name: Deploy
# Every push to main (and manual runs with the checkbox unticked) publishes a
# SNAPSHOT. SNAPSHOTs are mutable, so re-publishing the same version never collides.
- name: Deploy SNAPSHOT
if: inputs.release != true
env:
GPG_KEY_NAME: ${{ secrets.GPG_KEY_NAME }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
run: |
VERSION=$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout)
if [[ "$VERSION" != *-SNAPSHOT ]]; then
echo "::error::Version $VERSION is not a SNAPSHOT. Push-triggered runs only publish SNAPSHOTs; use the manual 'Release' run to cut a final version."
exit 1
fi
./mvnw -B -ntp deploy -DskipTests -Dgpg.keyname=${GPG_KEY_NAME} -Dgpg.passphrase=${GPG_PASSPHRASE}

# Manual run with the checkbox ticked: maven-release-plugin strips -SNAPSHOT,
# tags the release, deploys it to Maven Central, then bumps to the next
# -SNAPSHOT and pushes both commits + the tag back to main.
- name: Release
if: inputs.release == true
env:
GPG_KEY_NAME: ${{ secrets.GPG_KEY_NAME }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
run: ./mvnw -B -ntp deploy -DskipTests -Dgpg.keyname=${GPG_KEY_NAME} -Dgpg.passphrase=${GPG_PASSPHRASE}
GPG_KEY_NAME: ${{ secrets.GPG_KEY_NAME }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
run: |
./mvnw -B -ntp release:prepare release:perform \
-DskipTests \
-DlocalCheckout=true \
-Darguments="-DskipTests -Dgpg.keyname=${GPG_KEY_NAME} -Dgpg.passphrase=${GPG_PASSPHRASE}"
31 changes: 28 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

<groupId>org.asynchttpclient</groupId>
<artifactId>async-http-client-project</artifactId>
<version>3.0.11</version>
<version>3.0.12-SNAPSHOT</version>
<packaging>pom</packaging>

<name>AHC/Project</name>
Expand Down Expand Up @@ -68,8 +68,8 @@
</developers>

<scm>
<connection>scm:git:git@github.com:AsyncHttpClient/async-http-client.git</connection>
<developerConnection>scm:git:git@github.com:AsyncHttpClient/async-http-client.git</developerConnection>
<connection>scm:git:https://github.com/AsyncHttpClient/async-http-client.git</connection>
<developerConnection>scm:git:https://github.com/AsyncHttpClient/async-http-client.git</developerConnection>
<url>https://github.com/AsyncHttpClient/async-http-client/tree/main</url>
<tag>HEAD</tag>
</scm>
Expand Down Expand Up @@ -406,9 +406,34 @@
<extensions>true</extensions>
<configuration>
<publishingServerId>central</publishingServerId>
<autoPublish>true</autoPublish>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>3.3.1</version>
<configuration>
<autoVersionSubmodules>true</autoVersionSubmodules>
<tagNameFormat>async-http-client-project-@{project.version}</tagNameFormat>
<preparationGoals>clean verify</preparationGoals>
<signTag>false</signTag>
</configuration>
<dependencies>
<dependency>
<groupId>org.apache.maven.scm</groupId>
<artifactId>maven-scm-api</artifactId>
<version>2.2.1</version>
</dependency>
<dependency>
<groupId>org.apache.maven.scm</groupId>
<artifactId>maven-scm-provider-gitexe</artifactId>
<version>2.2.1</version>
</dependency>
</dependencies>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
Expand Down
Loading