Skip to content

Commit

Permalink
Issue #86. Configure with ModiTect parent and JReleaser
Browse files Browse the repository at this point in the history
  • Loading branch information
aalmiray authored and gunnarmorling committed Jan 14, 2022
1 parent 9524e36 commit 0446085
Show file tree
Hide file tree
Showing 129 changed files with 1,383 additions and 1,052 deletions.
64 changes: 24 additions & 40 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
# limitations under the License.
#

# This workflow will build a Java project with Maven
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven

name: Build

on:
Expand All @@ -28,54 +25,41 @@ on:
jobs:
build:
name: Build
if: github.repository == 'moditect/layrry' && startsWith(github.event.head_commit.message, '🏁 Releasing version') != true && startsWith(github.event.head_commit.message, '⬆️ Next version') != true
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: 'Check out repository'
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: 'Set up Java'
uses: actions/setup-java@v2
with:
java-version: 17
distribution: 'zulu'
- name: Cache Maven packages
uses: actions/cache@v2.1.7

- name: 'Cache Maven packages'
uses: actions/cache@v2
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Build with Maven
run: mvn install --file pom.xml

earlyaccess:
name: 'Early Access'
if: github.event_name == 'push' && github.repository == 'moditect/layrry' && github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: 'Set up Java'
uses: actions/setup-java@v2
with:
java-version: 17
distribution: 'zulu'

- name: Cache Maven packages
uses: actions/cache@v2.1.7
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: 'Build'
run: mvn install --file pom.xml

- name: Build with Maven
run: mvn -DskipTests verify --file pom.xml
- name: 'Release with JReleaser'
if: github.event_name == 'push'
env:
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./mvnw -B --file pom.xml -Pjreleaser jreleaser:release

- name: 'Release early-access artifacts'
uses: marvinpinto/action-automatic-releases@latest
with:
automatic_release_tag: 'early-access'
repo_token: ${{ secrets.GITHUB_TOKEN }}
prerelease: true
title: "Layrry Early-Access"
files: |
layrry-launcher/target/*-all.jar
layrry-launcher/target/distributions/*.zip
layrry-launcher/target/distributions/*.tar.gz
- name: 'JReleaser output'
if: github.event_name == 'push' && always()
uses: actions/upload-artifact@v2
with:
name: jreleaser-logs
path: |
target/jreleaser/trace.log
target/jreleaser/output.properties
109 changes: 71 additions & 38 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,66 +17,99 @@
name: Release

on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
version:
description: "Release version"
required: true
next:
description: "Next version"
required: false

jobs:
Release:
runs-on: ubuntu-latest
steps:
- name: Get the version
id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\/v/}

- name: Checkout
- name: 'Check out repository'
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: 'Set up Java'
uses: actions/setup-java@v2
with:
java-version: 17
distribution: 'zulu'
server-id: central
server-username: MAVEN_USERNAME
server-password: MAVEN_CENTRAL_TOKEN
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE

- name: Cache Maven
- name: 'Cache Maven packages'
uses: actions/cache@v2.1.7
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2

- name: Build Maven
run: mvn install --file pom.xml -DskipTests
- name: 'Set release version'
id: version
run: |
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
./mvnw -B versions:set versions:commit -DnewVersion=$RELEASE_VERSION
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global user.name "GitHub Action"
git commit -a -m "🏁 Releasing version $RELEASE_VERSION"
git push origin HEAD:master
echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITUB_ENV
echo "NEXT_VERSION=$NEXT_VERSION" >> $GITUB_ENV
- name: Create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
- name: 'Build'
run: |
chmod +x mvnw
./mvnw -B install --file pom.xml
- name: Upload zip
id: upload-zip
uses: actions/upload-release-asset@v1
- name: 'Release to Maven Central'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./layrry-launcher/target/distributions/layrry-launcher-${{ steps.get_version.outputs.VERSION }}-dist.zip
asset_name: layrry-launcher-${{ steps.get_version.outputs.VERSION }}.zip
asset_content_type: application/zip
MAVEN_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
MAVEN_CENTRAL_TOKEN: ${{ secrets.SONATYPE_PASSWORD }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
run: |
export GPG_TTY=$(tty)
export MAVEN_OPTS=--illegal-access=permit
./mvnw --no-transfer-progress -B --file pom.xml \
-Drepository.url=https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git \
-Dmaven.site.skip=true -Drelease=true deploy
- name: Upload tgz
id: upload-tgz
uses: actions/upload-release-asset@v1
- name: 'Release to GitHub'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
JRELEASER_SDKMAN_CONSUMER_KEY: ${{ secrets.JRELEASER_SDKMAN_CONSUMER_KEY }}
JRELEASER_SDKMAN_CONSUMER_TOKEN: ${{ secrets.JRELEASER_SDKMAN_CONSUMER_TOKEN }}
run: |
./mvnw -B --file pom.xml -pl :layrry-aggregator -Pjreleaser jreleaser:full-release
- name: 'JReleaser output'
if: always()
uses: actions/upload-artifact@v2
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./layrry-launcher/target/distributions/layrry-launcher-${{ steps.get_version.outputs.VERSION }}-dist.tar.gz
asset_name: layrry-launcher-${{ steps.get_version.outputs.VERSION }}.tar.gz
asset_content_type: application/gzip
name: jreleaser-logs
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 "41898282+github-actions[bot]@users.noreply.github.com"
git config --global user.name "GitHub Action"
git commit -a -m "⬆️ Next version ${{ env.NEXT_VERSION }}"
git push origin HEAD:master
31 changes: 31 additions & 0 deletions .mvn/release-settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!--
Copyright 2020 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.
-->
<settings>
<servers>
<server>
<id>gpg.passphrase</id>
<passphrase>${gpg.passphrase}</passphrase>
</server>
<server>
<id>central</id>
<username>${central.username}</username>
<password>${central.password}</password>
</server>
</servers>
</settings>

Loading

0 comments on commit 0446085

Please sign in to comment.