Deploy to Maven #4
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: Deploy to Maven | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| workflow_dispatch: | |
| jobs: | |
| validation: | |
| name: "Validation" | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: gradle/actions/wrapper-validation@v4 | |
| build-docker: | |
| needs: [validation] | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - container: wpilib/roborio-cross-ubuntu:2025-22.04 | |
| artifact-name: Athena | |
| build-options: "-Ponlylinuxathena" | |
| - container: wpilib/raspbian-cross-ubuntu:bookworm-22.04 | |
| artifact-name: Arm32 | |
| build-options: "-Ponlylinuxarm32" | |
| - container: wpilib/aarch64-cross-ubuntu:bookworm-22.04 | |
| artifact-name: Arm64 | |
| build-options: "-Ponlylinuxarm64" | |
| - container: wpilib/ubuntu-base:22.04 | |
| artifact-name: Linux | |
| build-options: "" | |
| name: "Build - ${{ matrix.artifact-name }}" | |
| runs-on: ubuntu-22.04 | |
| container: ${{ matrix.container }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: true | |
| fetch-depth: 0 | |
| - name: Fetch all history and metadata | |
| run: | | |
| git config --global --add safe.directory /__w/${{ github.event.repository.name }}/${{ github.event.repository.name }} | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@v4 | |
| with: | |
| cache-read-only: false | |
| - name: Build with Gradle | |
| run: ./gradlew build ${{ matrix.build-options }} | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ matrix.artifact-name }} | |
| path: build/allOutputs | |
| build-host: | |
| needs: [validation] | |
| env: | |
| MACOSX_DEPLOYMENT_TARGET: 13.3 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: windows-2022 | |
| artifact-name: Win64 | |
| architecture: x64 | |
| - os: macos-14 | |
| artifact-name: macOS | |
| architecture: aarch64 | |
| name: "Build - ${{ matrix.artifact-name }}" | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: true | |
| - name: Fetch all history and metadata | |
| run: git fetch --prune --unshallow | |
| - uses: actions/setup-java@v4 | |
| with: | |
| distribution: 'temurin' | |
| java-version: 17 | |
| architecture: ${{ matrix.architecture }} | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@v4 | |
| with: | |
| cache-read-only: false | |
| - name: Build with Gradle | |
| run: ./gradlew build -Pbuildalldesktop | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ matrix.artifact-name }} | |
| path: build/allOutputs | |
| publish-to-r2: | |
| name: Publish to R2 | |
| needs: [build-docker, build-host] | |
| runs-on: ubuntu-22.04 | |
| environment: main | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| path: build/allOutputs | |
| - name: Flatten Artifacts | |
| run: | | |
| mkdir -p build/allOutputs-flat | |
| rsync -a build/allOutputs/*/* build/allOutputs-flat/ | |
| rm -rf build/allOutputs | |
| mv build/allOutputs-flat build/allOutputs | |
| - uses: actions/setup-java@v4 | |
| with: | |
| distribution: 'temurin' | |
| java-version: 17 | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@v4 | |
| with: | |
| cache-read-only: false | |
| - name: Publish Maven Repository | |
| run: ./gradlew publish | |
| - name: Deploy to R2 | |
| env: | |
| AWS_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }} | |
| AWS_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }} | |
| AWS_DEFAULT_REGION: auto | |
| AWS_ENDPOINT_URL_S3: ${{ secrets.R2_ENDPOINT_URL }} | |
| run: | | |
| aws s3 sync build/repos/releases s3://${{ secrets.R2_BUCKET_NAME }} \ | |
| --cache-control "public, max-age=31536000" \ | |
| --delete | |
| - name: Summary | |
| run: | | |
| echo "Deployed to R2 bucket at $(date)" | |
| echo "Maven repository URL: ${{ secrets.R2_PUBLIC_URL }}" |