From b3946bce5744830ebeb6e5e5b75deff0c1d6b0d8 Mon Sep 17 00:00:00 2001 From: George Gastaldi Date: Wed, 11 Sep 2024 08:47:05 -0300 Subject: [PATCH] Add reusable workflows --- .github/dependabot.yml | 11 +++ .github/workflows/perform-release.yml | 101 ++++++++++++++++++++++++++ .github/workflows/prepare-release.yml | 77 ++++++++++++++++++++ .gitignore | 65 +++++++++++++++++ 4 files changed, 254 insertions(+) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/perform-release.yml create mode 100644 .github/workflows/prepare-release.yml create mode 100644 .gitignore diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..0d08e26 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,11 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file + +version: 2 +updates: + - package-ecosystem: "github-actions" # See documentation for possible values + directory: "/" # Location of package manifests + schedule: + interval: "weekly" diff --git a/.github/workflows/perform-release.yml b/.github/workflows/perform-release.yml new file mode 100644 index 0000000..6a39058 --- /dev/null +++ b/.github/workflows/perform-release.yml @@ -0,0 +1,101 @@ +name: Quarkiverse Perform Release + +on: + # Called in the release workflow + workflow_call: + secrets: + GH_TRIGGER_RELEASE_TOKEN: + required: true + inputs: + version: + required: true + description: Tag version to perform release + type: string + ref: + description: 'Branch or tag to deploy' + required: false + type: string + + # Can be triggered manually also + workflow_dispatch: + inputs: + version: + type: string + description: Tag version to perform release + required: true + ref: + description: 'Branch or tag to deploy' + type: string + required: false + +permissions: + attestations: write + id-token: write + contents: read + +defaults: + run: + shell: bash + +jobs: + perform-release: + runs-on: ubuntu-latest + steps: + - name: Set Release Version Environment Variable + run: | + echo "RELEASE_VERSION=${DISPATCH_VERSION:-${CALL_VERSION}}" >> $GITHUB_ENV + env: + CALL_VERSION: ${{ inputs.version }} + DISPATCH_VERSION: ${{ github.event.inputs.version}} + - name: Set Ref Environment Variable + run: | + echo "REF=${DISPATCH_REF:-${CALL_REF:-${RELEASE_VERSION}}}" >> $GITHUB_ENV + env: + CALL_REF: ${{ inputs.ref }} + DISPATCH_REF: ${{ github.event.inputs.ref}} + - name: Set ARTIFACT_PATH Environment Variable + run: | + echo "ARTIFACT_PATH=${REPOSITORY_NAME}-${RELEASE_VERSION}.tar.gz" >> $GITHUB_ENV + env: + REPOSITORY_NAME: ${{ github.event.repository.name }} + - uses: actions/checkout@v4 + with: + ref: ${{env.REF}} # The tag created by the release:prepare goal + + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: 21 + cache: 'maven' + + - name: Deploy release ${{env.RELEASE_VERSION}} + run: mvn deploy -DperformRelease -DaltDeploymentRepository=local::file://${{ github.workspace }}/repository + + - name: Tarball the artifacts + run: tar -czvf ${ARTIFACT_PATH} -C repository . + + - name: Generate artifact attestation + id: attest_build_provenance + uses: actions/attest-build-provenance@v1 + with: + subject-path: ${{env.ARTIFACT_PATH}} + + - name: Upload assets + uses: actions/upload-artifact@v4 + with: + path: ${{env.ARTIFACT_PATH}} + retention-days: 3 + + - name: Invoke Quarkiverse Release workflow + run: | + gh workflow run deploy-artifacts.yml -R smallrye/smallrye-release \ + -f github_repository=${GH_REPO} \ + -f run_id=${GH_RUN_ID} \ + -f version=${RELEASE_VERSION} \ + -f name=${ARTIFACT_NAME} + env: + GH_TOKEN: ${{ secrets.GH_TRIGGER_RELEASE_TOKEN }} + GH_REPO: ${{ github.repository }} + GH_RUN_ID: ${{ github.run_id }} + ARTIFACT_NAME: ${{ github.event.repository.name }} diff --git a/.github/workflows/prepare-release.yml b/.github/workflows/prepare-release.yml new file mode 100644 index 0000000..706309b --- /dev/null +++ b/.github/workflows/prepare-release.yml @@ -0,0 +1,77 @@ +name: Quarkiverse Prepare Release + +on: + workflow_call: + # Map the workflow outputs to job outputs + outputs: + release-version: + description: "Released Version" + value: ${{ jobs.prepare-release.outputs.release-version }} + next-version: + description: "Next Version" + value: ${{ jobs.prepare-release.outputs.next-version }} + +permissions: + contents: write + +jobs: + prepare-release: + runs-on: ubuntu-latest + name: Prepare Release + if: ${{github.event.pull_request.merged == true}} + # Map the job outputs to step outputs + outputs: + release-version: ${{ steps.out.outputs.release-version }} + next-version: ${{ steps.out.outputs.next-version }} + + steps: + - uses: actions/checkout@v4 + + - uses: radcortez/project-metadata-action@main + name: Retrieve project metadata + id: metadata + with: + github-token: ${{secrets.GITHUB_TOKEN}} + metadata-file-path: '.github/project.yml' + local-file: true + + - name: Set environment variables + run: | + echo "CURRENT_VERSION=${{steps.metadata.outputs.current-version}}" >> $GITHUB_ENV + echo "NEXT_VERSION=${{steps.metadata.outputs.next-version}}" >> $GITHUB_ENV + + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: 21 + cache: 'maven' + + - name: Configure Git author + run: | + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" + + - name: Update latest release version in docs + run: | + mvn -B -ntp -pl docs -am package -DskipTests -DskipITs -Denforcer.skip -Dformatter.skip -Dimpsort.skip + if ! git diff --quiet docs/modules/ROOT/pages/includes; then + git add docs/modules/ROOT/pages/includes + git commit -m "Update the latest release version ${{env.CURRENT_VERSION}} in documentation" + fi + + - name: Maven release ${{env.CURRENT_VERSION}} + run: | + mvn -B release:prepare -Prelease -DreleaseVersion=${CURRENT_VERSION} -DdevelopmentVersion=${NEXT_VERSION} -DscmCommentPrefix="[skip ci] " -Darguments="-Dgpg.skip=true" + mvn -B release:clean + + - name: Push changes to ${{github.base_ref}} branch and tag ${{env.CURRENT_VERSION}} + run: | + git push + git push origin ${CURRENT_VERSION} + + - name: Output release version + id: out + run: | + echo "release-version=${CURRENT_VERSION}" >> $GITHUB_OUTPUT + echo "next-version=${NEXT_VERSION}" >> $GITHUB_OUTPUT diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fbfa8cc --- /dev/null +++ b/.gitignore @@ -0,0 +1,65 @@ +# Compiled class file +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + +# Eclipse +.project +.classpath +.settings/ +bin/ + +# IntelliJ +.idea +*.ipr +*.iml +*.iws + +# NetBeans +nb-configuration.xml + +# Visual Studio Code +.vscode +.factorypath + +# OSX +.DS_Store + +# Vim +*.swp +*.swo + +# patch +*.orig +*.rej + +# Gradle +.gradle/ +build/ + +# Maven +target/ +pom.xml.tag +pom.xml.releaseBackup +pom.xml.versionsBackup +release.properties +.flattened-pom.xml