tofu-maker-cd #5
This file contains 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
# | |
# SPDX-License-Identifier: Apache-2.0 | |
# SPDX-FileCopyrightText: Huawei Inc. | |
# | |
--- | |
name: tofu-maker-cd | |
on: | |
workflow_dispatch: | |
inputs: | |
ReleaseType: | |
type: choice | |
description: Select the version to released | |
options: | |
- Major Version | |
- Minor Version | |
- Patch Version | |
env: | |
BOT_USER_NAME: eclipse-xpanse-bot | |
BOT_EMAIL_ID: [email protected] | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }} | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
if: github.repository == 'eclipse-xpanse/tofu-maker' | |
outputs: | |
next-version: ${{ steps.new_version.outputs.next-version }} | |
permissions: | |
contents: write | |
packages: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
token: ${{ secrets.BOT_GITHUB_TOKEN }} | |
- name: Set Up JDK 21 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: 21 | |
distribution: 'temurin' | |
gpg-private-key: ${{ secrets.ORG_GPG_PRIVATE_KEY }} | |
gpg-passphrase: ${{ secrets.ORG_GPG_PASSPHRASE }} | |
server-id: maven | |
- name: Set current version env variable | |
run: | | |
echo "CURRENT_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout | sed s/-SNAPSHOT/""/g)" >> $GITHUB_ENV | |
- name: Map input to next action | |
run: | | |
if [ "${{github.event.inputs.ReleaseType}}" = "Major Version" ]; then | |
echo "VERSION_FRAGMENT=major" >> $GITHUB_ENV | |
elif [ "${{github.event.inputs.ReleaseType}}" = "Minor Version" ]; then | |
echo "VERSION_FRAGMENT=feature" >> $GITHUB_ENV | |
elif [ "${{github.event.inputs.ReleaseType}}" = "Patch Version" ]; then | |
echo "VERSION_FRAGMENT=bug" >> $GITHUB_ENV | |
else | |
echo "No matching feature type found" | |
fi | |
- name: Set next development version environment variable | |
id: new_version | |
uses: christian-draeger/[email protected] | |
with: | |
current-version: ${{ env.CURRENT_VERSION }} | |
version-fragment: ${{ env.VERSION_FRAGMENT }} | |
- name: Update POMs to version to be released | |
run: mvn versions:set -DnewVersion=${{ steps.new_version.outputs.next-version }} -DgenerateBackupPoms=false | |
- name: Build | |
run: mvn clean install -DskipTests | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Github Packages | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ env.BOT_USER_NAME }} | |
password: ${{ secrets.BOT_GITHUB_DOCKER_TOKEN }} | |
- name: Extract Docker metadata | |
id: meta | |
uses: docker/[email protected] | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
- name: Build Docker Image and Push | |
uses: docker/[email protected] | |
with: | |
context: . | |
push: true | |
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.new_version.outputs.next-version }} | |
labels: ${{ steps.meta.outputs.labels }} | |
provenance: false | |
- name: Push POM updates with release version | |
uses: EndBug/add-and-commit@v9 | |
with: | |
message: "[GitHub Action] Update release version" | |
author_name: ${{ env.BOT_USER_NAME }} | |
committer_name: ${{ env.BOT_USER_NAME }} | |
author_email: ${{ env.BOT_EMAIL_ID }} | |
committer_email: ${{ env.BOT_EMAIL_ID }} | |
- name: Release new version on GitHub | |
env: | |
JRELEASER_GPG_PASSPHRASE: ${{ secrets.ORG_GPG_PASSPHRASE }} | |
JRELEASER_GPG_SECRET_KEY: ${{ secrets.ORG_GPG_PRIVATE_KEY }} | |
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.ORG_GPG_PUBLIC_KEY }} | |
JRELEASER_PROJECT_VERSION: ${{ steps.new_version.outputs.next-version }} | |
uses: jreleaser/release-action@v2 | |
with: | |
arguments: release | |
- name: Upload JReleaser release output | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: jreleaser-release | |
path: | | |
out/jreleaser/trace.log | |
out/jreleaser/output.properties | |
prepare-for-next-development-cycle: | |
runs-on: ubuntu-latest | |
if: github.repository == 'eclipse-xpanse/tofu-maker' | |
needs: release | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.ref }} | |
token: ${{ secrets.BOT_GITHUB_TOKEN }} | |
- name: Update next development version in POMs | |
run: mvn versions:set -DnewVersion=${{ needs.release.outputs.next-version }}-SNAPSHOT -DgenerateBackupPoms=false | |
- name: Push POM updates for next development cycle | |
uses: EndBug/add-and-commit@v9 | |
with: | |
message: "[GitHub Action] Prepare for next development cycle" | |
author_name: ${{ env.BOT_USER_NAME }} | |
committer_name: ${{ env.BOT_USER_NAME }} | |
author_email: ${{ env.BOT_EMAIL_ID }} | |
committer_email: ${{ env.BOT_EMAIL_ID }} |