build: tweaking build pipeline #8
Workflow file for this run
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
# standard github workflow for maven project with java8 | |
name: Java CI with Maven | |
on: | |
push: | |
tags: | |
- 'v*.*.*' | |
branches: [ master ] | |
pull_request: | |
branches: [ master ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set Build Version | |
run: | | |
if [[ "${{ github.ref }}" == "refs/tags/v"* ]]; then | |
TAG_VERSION=${GITHUB_REF#refs/tags/v} | |
echo "BUILD_VERSION=$TAG_VERSION" >> $GITHUB_ENV | |
else | |
echo "BUILD_VERSION=1.0.0-SNAPSHOT" >> $GITHUB_ENV | |
fi | |
- name: Set up JDK 1.8 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: 8 | |
- name: Build with Maven | |
run: mvn -B package -Drevision=${{ env.BUILD_VERSION }} --file pom.xml | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: build-artifacts | |
path: | | |
target/**/*.jar | |
target/**/*.zip | |
release: | |
if: startsWith(github.ref, 'refs/tags/v') | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download build artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: dpdirect | |
path: artifacts/ | |
- name: Create GitHub Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: artifacts/*.* | |
token: ${{ secrets.GITHUB_TOKEN }} | |
tag_name: ${{ github.ref }} | |
release_name: Release ${{ github.ref_name }} | |
body: "Automated release for version ${{ github.ref_name }}." |