From acdda9d27d609f77a7b5b919187fc5392cd48785 Mon Sep 17 00:00:00 2001 From: Taylor Becker Date: Tue, 29 Mar 2022 11:02:12 -0400 Subject: [PATCH] New release workflow with automatic latest/snapshot releasing (#7) --- .github/workflows/build-workflow.yml | 32 ++++++++++++++++++++++++++ .github/workflows/pr-workflow.yml | 12 +--------- .github/workflows/release-workflow.yml | 22 ++++++++++-------- 3 files changed, 46 insertions(+), 20 deletions(-) create mode 100644 .github/workflows/build-workflow.yml diff --git a/.github/workflows/build-workflow.yml b/.github/workflows/build-workflow.yml new file mode 100644 index 0000000..615931e --- /dev/null +++ b/.github/workflows/build-workflow.yml @@ -0,0 +1,32 @@ +name: Build +on: + workflow_call: + outputs: + version: + description: Built version + value: ${{ jobs.build.outputs.version }} + +jobs: + build: + name: Gradle Build + runs-on: ubuntu-latest + outputs: + version: ${{ steps.version.outputs.version }} + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-java@v2 + with: + java-version: 17 + distribution: temurin + - uses: gradle/gradle-build-action@v2 + - name: Gradle Build + run: ./gradlew build + - name: Get Version + id: version + run: echo ::set-output name=version::"$(./gradlew --console plain --quiet currentVersion -Prelease.quiet)" + - name: Upload build + uses: actions/upload-artifact@v3 + with: + name: build + path: build/libs/*.jar + retention-days: 7 diff --git a/.github/workflows/pr-workflow.yml b/.github/workflows/pr-workflow.yml index 1b60a68..28d2147 100644 --- a/.github/workflows/pr-workflow.yml +++ b/.github/workflows/pr-workflow.yml @@ -3,14 +3,4 @@ on: pull_request jobs: build: - name: Gradle Build - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-java@v2 - with: - java-version: 17 - distribution: temurin - - uses: gradle/gradle-build-action@v2 - with: - arguments: build + uses: ./.github/workflows/build-workflow.yml diff --git a/.github/workflows/release-workflow.yml b/.github/workflows/release-workflow.yml index 2ddd0a6..837f7c4 100644 --- a/.github/workflows/release-workflow.yml +++ b/.github/workflows/release-workflow.yml @@ -1,28 +1,32 @@ name: Release on: push: + branches: ['master', 'main'] # TODO: master/main tags: - "v[0-9]+.[0-9]+.[0-9]+" jobs: + build: + uses: ./.github/workflows/build-workflow.yml release: + needs: build name: Create Release runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: actions/setup-java@v2 + - name: Download build + uses: actions/download-artifact@v3 with: - java-version: 17 - distribution: temurin - - name: Gradle Build - uses: gradle/gradle-build-action@v2 - with: - arguments: build + name: build + path: build - name: Release uses: docker://antonyurchenko/git-release:v4 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - DRAFT_RELEASE: "true" + RELEASE_NAME: ${{ needs.build.outputs.version }} + PRE_RELEASE: ${{ github.ref_type == 'branch' }} + UNRELEASED: ${{ github.ref_type == 'branch' && 'update' || '' }} + UNRELEASED_TAG: latest-snapshot with: args: | - build/libs/*.jar + build/*.jar