Repository navigation
Decouple release channels; don't block CI on Central's publish queue #16
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Release | |
| on: | |
| push: | |
| tags: | |
| - '*' | |
| # Three independent channels. The GitHub release asset and the Docker image | |
| # must never be hostage to Maven Central: for 4.9 the Central publish queue | |
| # outlasted the plugin's poll window, the job "failed", and the release and | |
| # docker steps were skipped while Central went on to publish anyway. | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up JDK 11 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '11' | |
| distribution: 'temurin' | |
| cache: 'maven' | |
| # Set version from tag | |
| - name: Set version from tag | |
| run: | | |
| TAG_VERSION=${GITHUB_REF#refs/tags/v} | |
| mvn versions:set -DnewVersion=${TAG_VERSION} -DgenerateBackupPoms=false | |
| # Build and run tests | |
| - name: Build and test | |
| run: mvn -B package | |
| # The published Maven artifact is now the thin jar; use the runnable "shaded" jar as the | |
| # downloadable CLI release asset, keeping the familiar TestingBotTunnel-<version>.jar name. | |
| - name: Prepare runnable jar for release | |
| run: | | |
| VERSION=${GITHUB_REF#refs/tags/v} | |
| mkdir -p release-assets | |
| cp target/TestingBotTunnel-${VERSION}-shaded.jar release-assets/TestingBotTunnel-${VERSION}.jar | |
| # Upload the runnable JAR as a release asset | |
| - name: Upload JAR to GitHub Releases | |
| uses: softprops/action-gh-release@3d0d9888cb7fd7b750713d6e236d1fcb99157228 # v3 | |
| with: | |
| files: release-assets/TestingBotTunnel-*.jar | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| central: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up JDK 11 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '11' | |
| distribution: 'temurin' | |
| cache: 'maven' | |
| server-id: central | |
| server-username: MAVEN_USERNAME | |
| server-password: MAVEN_PASSWORD | |
| gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} | |
| gpg-passphrase: GPG_PASSPHRASE | |
| - name: Set version from tag | |
| run: | | |
| TAG_VERSION=${GITHUB_REF#refs/tags/v} | |
| mvn versions:set -DnewVersion=${TAG_VERSION} -DgenerateBackupPoms=false | |
| # Tests run in the build job; this job only deploys. | |
| - name: Deploy to Maven Central | |
| run: mvn -B clean deploy -DskipTests -Dgpg.passphrase=${{ secrets.GPG_PASSPHRASE }} | |
| env: | |
| MAVEN_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }} | |
| MAVEN_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }} | |
| GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} | |
| docker: | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up JDK 11 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '11' | |
| distribution: 'temurin' | |
| cache: 'maven' | |
| - name: Set version from tag | |
| run: | | |
| TAG_VERSION=${GITHUB_REF#refs/tags/v} | |
| echo "VERSION=${TAG_VERSION}" >> $GITHUB_ENV | |
| mvn versions:set -DnewVersion=${TAG_VERSION} -DgenerateBackupPoms=false | |
| - name: Build JAR | |
| run: mvn -B package -DskipTests | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v4 | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v4 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| platforms: linux/amd64,linux/arm64 | |
| push: true | |
| tags: | | |
| testingbot/tunnel:${{ env.VERSION }} | |
| testingbot/tunnel:latest |