-
Notifications
You must be signed in to change notification settings - Fork 4
89 lines (86 loc) · 3.71 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
on:
push:
branches:
- master
pull_request:
branches:
- master
release:
types:
- released
jobs:
build:
runs-on: ubuntu-latest
env:
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub_token: ${{ secrets.DOCKERHUB_TOKEN }}
steps:
- uses: actions/checkout@v3
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11'
- name: Version
id: set-version
run: |
set -x
VERSION=$(sed -nr 's/version ?= ?([^-]*).*/\1/p' gradle.properties)
[ $GITHUB_EVENT_NAME == 'release' ] && VERSION=${{ github.event.release.tag_name }} && VERSION=${VERSION/v/}
git tag -l | cat
[ $GITHUB_EVENT_NAME == 'push' ] && VERSION+=-beta && VERSION+=.$(($(git tag -l "$VERSION.*" | sed "s/$VERSION//" | sort -nt. -k2 2>/dev/null | tail -1 | rev | cut -d. -f1 | rev)+1))
[ $GITHUB_EVENT_NAME == 'pull_request' ] && VERSION+=-dev.${{ github.event.pull_request.number }}
NAME=$(sed -nr 's/rootProject.name ?= ?"?([^"]*)"?/\1/p' settings.gradle)-$VERSION
echo version=$VERSION >> $GITHUB_OUTPUT
echo name=$NAME >> $GITHUB_OUTPUT
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1
- name: Build with Gradle
run: ./gradlew -Pversion="${{ steps.set-version.outputs.version }}" build
- name: Publish asset
if: (github.event_name != 'pull_request')
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ steps.set-version.outputs.version }}
prerelease: ${{ github.event_name != 'release' }}
files: build/libs/${{ steps.set-version.outputs.name }}.jar
token: ${{ secrets.GITHUB_TOKEN }}
- name: Login to Docker Hub
if: env.dockerhub_username != '' && env.dockerhub_token != '' && github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up QEMU
if: env.dockerhub_username != '' && env.dockerhub_token != '' && github.event_name != 'pull_request'
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
if: env.dockerhub_username != '' && env.dockerhub_token != '' && github.event_name != 'pull_request'
uses: docker/setup-buildx-action@v2
with:
platforms: linux/amd64,linux/arm64
- name: Docker image
if: env.dockerhub_username != '' && env.dockerhub_token != '' && github.event_name != 'pull_request'
run: |
mkdir plugins
IMAGE=litesolutions/jenkins-objectscriptquality
[ $GITHUB_EVENT_NAME == 'release' ] && TAGS="-t ${IMAGE}:latest -t ${IMAGE}:${{ steps.set-version.outputs.version }}"
[ $GITHUB_EVENT_NAME == 'push' ] && TAGS="-t ${IMAGE}:beta"
docker buildx build --platform linux/arm64,linux/amd64 ${TAGS} --push -f jenkins/Dockerfile .
release:
runs-on: ubuntu-latest
if: github.event_name == 'release'
steps:
- uses: actions/checkout@v3
with:
ref: master
- name: Bump release
run: |
VERSION=${{ github.event.release.tag_name }}
NEXT_VERSION=`echo $VERSION | awk -F. '/[0-9]+\./{$NF++;print}' OFS=.`
git config --global user.name 'ProjectBot'
git config --global user.email '[email protected]'
sed -i -r "s/(version ?= ?).*/\1${NEXT_VERSION}-SNAPSHOT/" gradle.properties
git add gradle.properties
git commit -m 'auto bump version with release'
git push