Skip to content

Commit

Permalink
Workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiasDeBruijn committed Jun 23, 2021
1 parent 1ad3898 commit dd1fdab
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Java CI with Gradle

on:
push:
branches:
- '*'
pull_request:
branches:
- '*'

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.16
uses: actions/setup-java@v1
with:
java-version: 1.16

# Build with gradle
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build
70 changes: 70 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Release on tag
on:
push:
tags:
- '**'

jobs:
create-release:
runs-on: ubuntu-latest
steps:
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false

- name: Set output variables
id: export_vars
run: |
export RELEASE_UPLOAD_URL="${{ steps.create_release.outputs.upload_url }}"
echo "::set-output name=release_upload_url::${RELEASE_UPLOAD_URL}"
outputs:
release_upload_url: ${{ steps.export_vars.outputs.release_upload_url }}

build-java-11:
needs: create-release
runs-on: ubuntu-latest
steps:
#Checkout
- uses: actions/checkout@v2

#Setup Java 16
- name: Set up Java 16
uses: actions/setup-java@v1
with:
java-version: 1.16

#Apply permissions for Gradle, so that ./gradlew can run
- name: Grant execute permission for gradlew
run: chmod +x gradlew

#Build the JAR
- name: Build with Gradle
run: ./gradlew ghActions

#Extract version number
- name: Extract version number
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV

#Extract repository name
- name: Extract repository name
run: echo "REPOSITORY_NAME=$(echo "$GITHUB_REPOSITORY" | awk -F / '{print $2}' | sed -e "s/:refs//")" >> $GITHUB_ENV

#Attach compiled JAR to ReleaseS
- name: Attach JAR to Release
id: upload_release_asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.release_upload_url }}
asset_path: actions/output.jar
asset_name: ${{ env.REPOSITORY_NAME }}-${{ env.RELEASE_VERSION }}-RELEASE.jar
asset_content_type: application/java-archive

0 comments on commit dd1fdab

Please sign in to comment.