diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml new file mode 100644 index 0000000..f192fab --- /dev/null +++ b/.github/workflows/gradle.yml @@ -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 \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..09d4851 --- /dev/null +++ b/.github/workflows/release.yml @@ -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 \ No newline at end of file