Release Branch Workflow #5
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: Release Branch Workflow | |
| on: | |
| push: | |
| branches: | |
| - release/* | |
| workflow_run: | |
| workflows: | |
| - Create Release Branch Workflow | |
| types: | |
| - completed | |
| jobs: | |
| build-jars: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up JDK 21 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '21' | |
| distribution: 'corretto' | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@v4 | |
| - name: Build with Gradle Wrapper | |
| run: ./gradlew build | |
| - name: Extract project name from Gradle | |
| id: extract_name | |
| run: | | |
| PROJECT_NAME=$(./gradlew -q printProjectName) | |
| echo "PROJECT_NAME=${PROJECT_NAME}" >> $GITHUB_ENV | |
| - name: Extract version from Gradle | |
| id: get-version | |
| run: | | |
| VERSION=$(./gradlew -q printProjectVersion) | |
| echo "VERSION=${VERSION}" >> $GITHUB_ENV | |
| - name: Upload jars | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ env.PROJECT_NAME }}-${{ env.VERSION }}-jars | |
| path: build/libs/*.jar | |
| build-and-push-docker: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| packages: write | |
| id-token: write | |
| attestations: write | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: ${{ github.repository }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract version from file | |
| run: | | |
| VERSION=$(./gradlew -q printProjectVersion) | |
| echo "VERSION=${VERSION}" >> $GITHUB_ENV | |
| - name: Extract metadata (tags, labels) for Docker | |
| id: meta | |
| uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
| - name: Change wrapper permissions | |
| run: chmod +x ./gradlew | |
| - name: Build and push Docker image | |
| id: push | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }}, ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest | |
| labels: ${{ steps.meta.outputs.labels }} | |
| - name: Generate artifact attestation | |
| uses: actions/attest-build-provenance@v1 | |
| with: | |
| subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}} | |
| subject-digest: ${{ steps.push.outputs.digest }} | |
| push-to-registry: true | |
| package-and-push-helm: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Configure Git | |
| run: | | |
| git config user.name "$GITHUB_ACTOR" | |
| git config user.email "[email protected]" | |
| - name: Install Helm | |
| uses: azure/setup-helm@v4 | |
| env: | |
| GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | |
| - name: Run chart-releaser | |
| uses: helm/[email protected] | |
| with: | |
| packages_with_index: true | |
| env: | |
| CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | |
| - name: Package Helm Chart | |
| run: | | |
| helm package ./charts/default --destination ./chart | |
| - name: Extract project name from Gradle | |
| id: extract_name | |
| run: | | |
| PROJECT_NAME=$(./gradlew -q printProjectName) | |
| echo "PROJECT_NAME=${PROJECT_NAME}" >> $GITHUB_ENV | |
| - name: Extract version from Gradle | |
| id: get-version | |
| run: | | |
| VERSION=$(./gradlew -q printProjectVersion) | |
| echo "VERSION=${VERSION}" >> $GITHUB_ENV | |
| - name: Upload Helm Chart | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ env.PROJECT_NAME }}-${{ env.VERSION }}-helm-chart | |
| path: chart/*.tgz | |
| create-release: | |
| runs-on: ubuntu-latest | |
| needs: | |
| - build-jars | |
| - package-and-push-helm | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Extract project name from Gradle | |
| id: extract_name | |
| run: | | |
| PROJECT_NAME=$(./gradlew -q printProjectName) | |
| echo "PROJECT_NAME=${PROJECT_NAME}" >> $GITHUB_ENV | |
| - name: Extract version from Gradle | |
| id: get-version | |
| run: | | |
| VERSION=$(./gradlew -q printProjectVersion) | |
| echo "VERSION=${VERSION}" >> $GITHUB_ENV | |
| - name: Download jars | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: ${{ env.PROJECT_NAME }}-${{ env.VERSION }}-jars | |
| path: artifacts/ | |
| - name: Download Helm Chart | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: ${{ env.PROJECT_NAME }}-${{ env.VERSION }}-helm-chart | |
| path: artifacts/ | |
| - name: Release | |
| uses: softprops/action-gh-release@v2 | |
| if: true | |
| with: | |
| tag_name: ${{ env.VERSION }} | |
| body_path: ./CHANGELOG.md | |
| files: | | |
| artifacts/* | |
| dependency-submission: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up JDK 21 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '21' | |
| distribution: 'corretto' | |
| - name: Generate and submit dependency graph | |
| uses: gradle/actions/dependency-submission@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0 |