Skip to content

Commit

Permalink
actions workflow updated
Browse files Browse the repository at this point in the history
  • Loading branch information
daimor committed Feb 1, 2021
1 parent b9f37e2 commit 3e2ee33
Showing 1 changed file with 83 additions and 4 deletions.
87 changes: 83 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,94 @@ on:
push:
branches:
- main
pull_request:
branches:
- main
release:
types:
- released
jobs:
jar:
build:
runs-on: ubuntu-latest
outputs:
name: ${{ steps.build.outputs.name }}
version: ${{ steps.build.outputs.version }}
steps:
- uses: actions/checkout@v2
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* || true
- uses: actions/setup-java@v1
with:
java-version: '1.8'
- name: build jar
id: build
run: |
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
[ $GITHUB_EVENT_NAME == 'release' ] && VERSION=${{ github.event.release.tag_name }} && VERSION=${VERSION/v/}
[ $GITHUB_EVENT_NAME == 'push' ] && VERSION+=-beta && VERSION+=.$(($(git tag -l "v$VERSION.*" | sort -nt. -k4 2>/dev/null | tail -1 | cut -d. -f4)+1))
[ $GITHUB_EVENT_NAME == 'pull_request' ] && VERSION+=-dev.${{ github.event.pull_request.number }}
mvn versions:set -DnewVersion=$VERSION
mvn --batch-mode package
NAME=$(mvn help:evaluate -Dexpression=project.artifactId -q -DforceStdout)-$VERSION
echo ::set-output name=name::$NAME
echo ::set-output name=version::$VERSION
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/upload-artifact@v2
with:
name: ${{ steps.build.outputs.name }}.jar
path: target/${{ steps.build.outputs.name }}.jar
release:
runs-on: ubuntu-latest
needs:
- build
steps:
- uses: actions/checkout@master
- uses: actions/download-artifact@v2
with:
name: ${{ needs.build.outputs.name }}.jar
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ needs.build.outputs.version }}
release_name: v${{ needs.build.outputs.version }}
prerelease: ${{ github.event_name != 'release' }}
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ needs.build.outputs.name }}.jar
asset_name: ${{ needs.build.outputs.name }}.jar
asset_content_type: application/zip
deploy:
runs-on: ubuntu-latest
if: (github.event_name == 'release')
needs:
- build
steps:
- uses: actions/checkout@v2
with:
ref: main
- uses: actions/setup-java@v1
with:
java-version: '1.8'
- name: build and deploy jar
run: mvn --batch-mode deploy
- name: build jar
id: build
env:
VERSION: ${{ steps.build.outputs.version }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
mvn versions:set -DnewVersion=$VERSION
mvn --batch-mode deploy
VERSION=`echo $VERSION | awk -F. '/[0-9]+\./{$NF++;print}' OFS=.`
mvn versions:set -DnewVersion=$VERSION
mvn versions:commit
git config --global user.name 'ProjectBot'
git config --global user.email '[email protected]'
git add pom.xml
git commit -m 'auto bump version with release'

0 comments on commit 3e2ee33

Please sign in to comment.