docker login #35
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
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
branches: | |
- master | |
release: | |
types: | |
- released | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
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: 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.version.outputs.version }}" build | |
- name: Create Beta Release | |
if: (github.event_name == 'push') | |
uses: softprops/action-gh-release@v1 | |
with: | |
tag_name: v${{ steps.set-version.outputs.version }} | |
prerelease: ${{ github.event_name != 'release' }} | |
files: build/libs/${{ steps.version.outputs.name }}.jar | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Login to Docker Hub | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Set up QEMU | |
if: github.event_name != 'pull_request' | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
if: github.event_name != 'pull_request' | |
uses: docker/setup-buildx-action@v2 | |
with: | |
platforms: linux/amd64,linux/arm64 | |
- name: Docker image | |
if: 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 |