Testing GitHub workflows #1
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
name: Build | |
on: | |
push: | |
tags: | |
- 'v*' | |
env: | |
PROJECT_ID: "362368" | |
permissions: | |
contents: write | |
jobs: | |
main: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v2 | |
with: | |
java-version: '17' | |
distribution: 'adopt' | |
- name: Get Version | |
id: version | |
uses: actions/[email protected] | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
result-encoding: string | |
script: | | |
let ref = '${{ github.ref }}'; | |
return ref.startsWith('refs/tags/v') ? ref.replace('refs/tags/v', '') : 'indev'; | |
- name: Get Version Type | |
id: version_type | |
uses: actions/[email protected] | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
result-encoding: string | |
script: | | |
let version = '${{ steps.version.outputs.result }}'; | |
return version.includes('alpha') ? 'alpha' : (version.includes('beta') ? 'beta' : (version == 'indev' ? 'indev' : 'release')); | |
- name: Log Version Info | |
env: | |
VERSION: ${{ steps.version.outputs.result }} | |
VERSION_TYPE: ${{ steps.version_type.outputs.result }} | |
run: echo "version = $VERSION, type = $VERSION_TYPE" | |
- name: Build | |
uses: gradle/gradle-build-action@v2 | |
with: | |
arguments: build | |
env: | |
VERSION: ${{ steps.version.outputs.result }} | |
- name: Create Release | |
id: create_release | |
if: ${{ steps.version.outputs.result != 'indev' && success() }} | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: v${{ steps.version.outputs.result }} | |
release_name: DynamicTrees TFC v${{ steps.version.outputs.result }} | |
body: | | |
Version ${{ steps.version.outputs.result }} | |
### Changes | |
- todo: document changes | |
draft: true | |
prerelease: ${{ steps.version_type.outputs.result != 'release' }} | |
- name: Upload Main Jar | |
id: upload_main_jar | |
if: ${{ steps.version.outputs.result != 'indev' && success() }} | |
uses: actions/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./build/libs/dttfc-${{ steps.version.outputs.result }}.jar | |
asset_name: dttfc-${{ steps.version.outputs.result }}.jar | |
asset_content_type: application/java-archive |