Skip to content

Commit

Permalink
Added the github release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
gnmyt committed Jul 31, 2021
1 parent 056bb62 commit 485da40
Showing 1 changed file with 78 additions and 0 deletions.
78 changes: 78 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Java CI

on:
push:
branches: [master]

jobs:
create_release:
name: Create Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Get version
id: get_version
run: echo "::set-output name=version::$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' exec:exec)"
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.get_version.outputs.version }}
release_name: Release ${{ steps.get_version.outputs.version }}
draft: false
prerelease: false

- name: Output Release URL File
run: echo "${{ steps.create_release.outputs.upload_url }}" > release_url.txt

- name: Save Release URL File for publish
uses: actions/upload-artifact@v1
with:
name: release_url
path: release_url.txt

build_upload:
name: Build & Upload
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 8
uses: actions/setup-java@v2
with:
java-version: '8'
distribution: 'adopt'
- name: Build with Maven
run: mvn clean compile assembly:single

- name: Get version
id: get_version
run: echo "::set-output name=version::$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' exec:exec)"

- name: Get artifact id
id: get_artifact_id
run: echo "::set-output name=name::$(mvn -q -Dexec.executable=echo -Dexec.args='${project.artifactId}' exec:exec)"

- name: Load Release URL File from release job
uses: actions/download-artifact@v1
with:
name: release_url

- name: Get Release File Name & Upload URL
id: get_release_info
shell: bash
run: |
value=`cat release_url/release_url.txt`
echo ::set-output name=upload_url::$value
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.get_release_info.outputs.upload_url }}
asset_path: ./target/${{ steps.get_artifact_id.outputs.name }}-${{ steps.get_version.outputs.version }}-jar-with-dependencies.jar
asset_name: ${{ steps.get_artifact_id.outputs.name }}${{ steps.get_artifact_version.outputs.version }}.jar
asset_content_type: application/java-archive

0 comments on commit 485da40

Please sign in to comment.