Skip to content

Commit

Permalink
Add reusable workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
gastaldi committed Sep 11, 2024
0 parents commit b3946bc
Show file tree
Hide file tree
Showing 4 changed files with 254 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -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"
101 changes: 101 additions & 0 deletions .github/workflows/perform-release.yml
Original file line number Diff line number Diff line change
@@ -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 }}
77 changes: 77 additions & 0 deletions .github/workflows/prepare-release.yml
Original file line number Diff line number Diff line change
@@ -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
65 changes: 65 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit b3946bc

Please sign in to comment.