Skip to content

Release

Release #12

Workflow file for this run

name: Release
on:
workflow_dispatch:
inputs:
version:
description: 'Release version'
required: true
version-fragment:
description: 'Version fragment to increase for next development cycle'
required: true
default: 'minor'
type: choice
options:
- major
- minor
- patch
env:
BOT_USER_NAME: eclipse-cbi-bot
BOT_EMAIL: [email protected]
JAVA_VERSION: 17
JAVA_DISTRO: 'temurin'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
jobs:
precheck:
runs-on: ubuntu-22.04
permissions:
contents: write
if: github.repository == 'eclipse-cbi/macos-notarization-service'
outputs:
release-version: ${{ steps.prepare-release.outputs.RELEASE_VERSION }}
steps:
- name: Check ref
shell: bash
run: |
if [ "${{ github.ref }}" != "refs/heads/main" ]; then
echo "Release shall only be made from 'main' branch, triggered branch '${{ github.ref_name }}', aborting."
exit 1
fi
- name: Setup Git User
run: |
git config --global user.name '${{ env.BOT_USER_NAME }}'
git config --global user.email '${{ env.BOT_EMAIL }}'
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
ref: ${{ github.ref }}
fetch-depth: 0
- name: Setup Java
uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 # v3.13.0
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.JAVA_DISTRO }}
cache: maven
- name: Prepare release
id: prepare-release
shell: bash
run: |
PROJECT_VERSION="$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)"
RELEASE_VERSION="${{ github.event.inputs.version }}"
echo "PROJECT_VERSION=$(echo $PROJECT_VERSION)" >> $GITHUB_OUTPUT
echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_OUTPUT
echo "Project version: $PROJECT_VERSION"
echo "Release version: $RELEASE_VERSION"
if git show-ref --tags --verify --quiet "refs/tags/v${RELEASE_VERSION}"; then
echo "Release Tag 'v${RELEASE_VERSION}' already exists, aborting."
exit 1
fi
if [ "$PROJECT_VERSION" != "$RELEASE_VERSION" ]; then
./mvnw -B versions:set versions:commit -DnewVersion=$RELEASE_VERSION
git commit -a -m "Releasing version $RELEASE_VERSION"
git push origin ${{ github.ref }}
fi
release:
needs: ['precheck']
permissions:
contents: write
actions: read
packages: write
id-token: write
uses: jreleaser/release-action/.github/workflows/builder_slsa3.yml@java
with:
project-version: ${{ needs.precheck.outputs.release-version }}
branch: ${{ github.ref_name }}
jreleaser-version: '1.9.0'
java-version: 17
java-distribution: 'temurin'
rekor-log-public: true
secrets:
github-token: ${{ secrets.GITHUB_TOKEN }}
prepare-for-next-development-cycle:
runs-on: ubuntu-22.04
needs: ['precheck', 'release']
permissions:
contents: write
steps:
- name: Setup Git User
run: |
git config --global user.name '${{ env.BOT_USER_NAME }}'
git config --global user.email '${{ env.BOT_EMAIL }}'
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
ref: ${{ github.ref }}
- name: Setup Java
uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 # v3.13.0
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.JAVA_DISTRO }}
cache: maven
- id: increase-semver
uses: ./.github/actions/increase-semver
with:
current-version: ${{ needs.precheck.outputs.release-version }}
version-fragment: ${{ github.event.inputs.version-fragment }}
- name: Update next development version in POMs
run: |
./mvnw -B versions:set versions:commit -DnewVersion=${{ steps.increase-semver.outputs.next-version }}-SNAPSHOT -DgenerateBackupPoms=false
git commit -a -m "Prepare for next development cycle"
git push origin ${{ github.ref }}