-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f013cf8
commit f9e505b
Showing
1 changed file
with
243 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,243 @@ | ||
# | ||
# Copyright 2022 The original 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 | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: "Release version" | ||
required: true | ||
next: | ||
description: "Next version" | ||
required: false | ||
|
||
jobs: | ||
version: | ||
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/[email protected] | ||
with: | ||
path: ~/.m2 | ||
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} | ||
restore-keys: ${{ runner.os }}-m2 | ||
|
||
- name: 'Set release version' | ||
id: version | ||
run: | | ||
echo ${{ 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 | ||
./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 | ||
echo "removed: origin HEAD:master" | ||
git rev-parse HEAD > HEAD | ||
echo $RELEASE_VERSION > RELEASE_VERSION | ||
echo $PLAIN_VERSION > PLAIN_VERSION | ||
echo $NEXT_VERSION > NEXT_VERSION | ||
- name: 'Upload version files' | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: artifacts | ||
path: | | ||
HEAD | ||
*_VERSION | ||
# Build native executable per runner | ||
build: | ||
needs: [ version ] | ||
name: 'Build with Graal on ${{ matrix.os }}' | ||
strategy: | ||
fail-fast: true | ||
matrix: | ||
os: [ ubuntu-latest, macOS-latest, windows-latest ] | ||
gu-binary: [ gu, gu.cmd ] | ||
exclude: | ||
# Exclude GraalVM native image builds | ||
- os: ubuntu-latest | ||
gu-binary: gu.cmd | ||
- os: macos-latest | ||
gu-binary: gu.cmd | ||
- os: windows-latest | ||
gu-binary: gu | ||
# Temporarily excluding builds for testing | ||
# TODO: Remove this exclusion once we have native image builds for all platforms | ||
# - os: ubuntu-latest | ||
# gu-binary: gu | ||
# - os: macos-latest | ||
# gu-binary: gu | ||
runs-on: ${{ matrix.os }} | ||
|
||
steps: | ||
- name: 'Download all build artifacts' | ||
uses: actions/download-artifact@v2 | ||
|
||
- name: 'Read HEAD ref' | ||
id: head | ||
uses: juliangruber/read-file-action@v1 | ||
with: | ||
path: artifacts/HEAD | ||
|
||
- name: 'Check out repository' | ||
uses: actions/checkout@v2 | ||
with: | ||
ref: ${{ steps.head.outputs.content }} | ||
|
||
- name: 'Add Developer Command Prompt for Microsoft Visual C++ ' | ||
if: ${{ runner.os == 'Windows' }} | ||
uses: ilammy/msvc-dev-cmd@v1 | ||
|
||
- name: 'Set up Graal' | ||
uses: DeLaGuardo/[email protected] | ||
with: | ||
graalvm: '21.3.0' | ||
java: 'java17' | ||
|
||
- name: 'Install native-image component' | ||
run: | | ||
${{ matrix.gu-binary }} install native-image | ||
- name: 'Cache Maven packages' | ||
uses: actions/[email protected] | ||
with: | ||
path: ~/.m2 | ||
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} | ||
restore-keys: ${{ runner.os }}-m2 | ||
|
||
- name: 'Build Native Image' | ||
run: ./mvnw -B --file pom.xml -Pnative package | ||
|
||
# - run: | | ||
# dir | ||
# dir target | ||
# pwd | ||
|
||
# - run: | | ||
# ls -a | ||
# ls -a target | ||
# pwd | ||
# | ||
- name: 'Create distribution' | ||
run: ./mvnw -B --file pom.xml -Pdist package -DskipTests | ||
|
||
- name: 'Upload build artifact' | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: artifacts | ||
path: | | ||
target/*.zip | ||
target/*.tar.gz | ||
# Collect all executables and release | ||
release: | ||
needs: [ build ] | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
# must read HEAD before checkout | ||
- name: 'Download all build artifacts' | ||
uses: actions/download-artifact@v2 | ||
|
||
- name: 'Read HEAD ref' | ||
id: head | ||
uses: juliangruber/read-file-action@v1 | ||
with: | ||
path: artifacts/HEAD | ||
|
||
- name: 'Read versions' | ||
id: version | ||
run: | | ||
RELEASE_VERSION=`cat artifacts/RELEASE_VERSION` | ||
PLAIN_VERSION=`cat artifacts/PLAIN_VERSION` | ||
NEXT_VERSION=`cat artifacts/NEXT_VERSION` | ||
echo "RELEASE_VERSION = $RELEASE_VERSION" | ||
echo "PLAIN_VERSION = $PLAIN_VERSION" | ||
echo "NEXT_VERSION = $NEXT_VERSION" | ||
echo "::set-output name=RELEASE_VERSION::$RELEASE_VERSION" | ||
echo "::set-output name=PLAIN_VERSION::$PLAIN_VERSION" | ||
echo "::set-output name=NEXT_VERSION::$NEXT_VERSION" | ||
- name: 'Check out repository' | ||
uses: actions/checkout@v2 | ||
with: | ||
ref: ${{ steps.head.outputs.content }} | ||
fetch-depth: 0 | ||
|
||
# checkout will clobber downloaded artifacts | ||
# we have to download them again | ||
- name: 'Download all build artifacts' | ||
uses: actions/download-artifact@v2 | ||
|
||
- name: 'Set up Java' | ||
uses: actions/setup-java@v2 | ||
with: | ||
java-version: 17 | ||
distribution: 'zulu' | ||
|
||
- name: 'Cache Maven packages' | ||
uses: actions/[email protected] | ||
with: | ||
path: ~/.m2 | ||
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} | ||
restore-keys: ${{ runner.os }}-m2 | ||
|
||
- name: 'Release with JReleaser' | ||
env: | ||
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_HOMEBREW_GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} | ||
run: ./mvnw -B --file pom.xml -Prelease -DartifactsDir=artifacts jreleaser:full-release | ||
|
||
- name: JReleaser output | ||
if: always() | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: jreleaser-logs | ||
path: | | ||
target/jreleaser/trace.log | ||
target/jreleaser/output.properties | ||
- name: 'Set next version' | ||
env: | ||
NEXT_VERSION: ${{ steps.version.outputs.NEXT_VERSION }} | ||
run: | | ||
./mvnw -B versions:set versions:commit -DnewVersion=$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 $NEXT_VERSION" | ||
git push origin HEAD:master | ||
echo "removed: origin HEAD:master" |