Skip to content

Release

Release #18

Workflow file for this run

#
# Copyright 2020-2023 The ModiTect authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
name: Release
env:
JAVA_VERSION: '17'
JAVA_DISTRO: 'zulu'
USER_EMAIL: '41898282+github-actions[bot]@users.noreply.github.com'
USER_NAME: 'GitHub Action'
on:
workflow_dispatch:
inputs:
version:
description: "Release version"
required: true
next:
description: "Next version"
required: false
jobs:
Release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Java
uses: actions/setup-java@v3
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.JAVA_DISTRO }}
cache: maven
- name: Test Build Readiness
run: |
export GPG_TTY=$(tty)
chmod +x mvnw
./mvnw -ntp -B --file pom.xml -Dmaven.site.skip=true -Drelease=true verify -e
./mvnw -ntp -B --file pom.xml clean
- name: Set release version
id: version
run: |
BRANCH="layrry-${{ github.event.inputs.version }}"
RELEASE_VERSION=${{ github.event.inputs.version }}
NEXT_VERSION=${{ github.event.inputs.next }}
PLAIN_VERSION=`echo ${RELEASE_VERSION} | awk 'match($0, /^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)/) { print substr($0, RSTART, RLENGTH); }'`
COMPUTED_NEXT_VERSION="${PLAIN_VERSION}-SNAPSHOT"
if [ -z $NEXT_VERSION ]
then
NEXT_VERSION=$COMPUTED_NEXT_VERSION
fi
echo "BRANCH=$BRANCH" >> $GITHUB_ENV
echo "NEXT_VERSION=$NEXT_VERSION" >> $GITHUB_ENV
git config --global user.email "${{ env.USER_EMAIL }}"
git config --global user.name "${{ env.USER_NAME }}"
git checkout -b $BRANCH
./mvnw -ntp -B versions:set versions:commit -DnewVersion=$RELEASE_VERSION
git commit -a -m "🏁 Releasing version $RELEASE_VERSION"
git push origin $BRANCH
- name: Stage artifacts
run: |
./mvnw -ntp -B --file pom.xml -Ppublication -DaltDeploymentRepository=local::file:target/staging-deploy \
-Dmaven.site.skip=true install deploy -e
- name: Release
env:
JRELEASER_BRANCH: ${{ env.BRANCH }}
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
JRELEASER_SDKMAN_CONSUMER_KEY: ${{ secrets.JRELEASER_SDKMAN_CONSUMER_KEY }}
JRELEASER_SDKMAN_CONSUMER_TOKEN: ${{ secrets.JRELEASER_SDKMAN_CONSUMER_TOKEN }}
JRELEASER_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.GPG_PUBLIC_KEY }}
JRELEASER_GPG_SECRET_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
JRELEASER_TWITTER_CONSUMER_KEY: ${{ secrets.JRELEASER_TWITTER_CONSUMER_KEY }}
JRELEASER_TWITTER_CONSUMER_SECRET: ${{ secrets.JRELEASER_TWITTER_CONSUMER_SECRET }}
JRELEASER_TWITTER_ACCESS_TOKEN: ${{ secrets.JRELEASER_TWITTER_ACCESS_TOKEN }}
JRELEASER_TWITTER_ACCESS_TOKEN_SECRET: ${{ secrets.JRELEASER_TWITTER_ACCESS_TOKEN_SECRET }}
JRELEASER_MASTODON_ACCESS_TOKEN: ${{ secrets.JRELEASER_MASTODON_ACCESS_TOKEN }}
JRELEASER_NEXUS2_MAVEN_CENTRAL_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
JRELEASER_NEXUS2_MAVEN_CENTRAL_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
run: |
./mvnw -ntp -B -pl :layrry-aggregator -Pjreleaser jreleaser:full-release
- name: JReleaser output
if: always()
uses: actions/upload-artifact@v3
with:
name: jreleaser
path: |
target/jreleaser/trace.log
target/jreleaser/output.properties
- name: Set next version
run: |
./mvnw -B versions:set versions:commit -DnewVersion=${{ env.NEXT_VERSION }}
git config --global user.email "${{ env.USER_EMAIL }}"
git config --global user.name "${{ env.USER_NAME }}"
git commit -a -m "⬆️ Next version ${{ env.NEXT_VERSION }}"
git push origin ${{ env.BRANCH }}