Release and publish in the same action.

This commit is contained in:
Jeremy Wood 2023-02-19 22:51:30 -05:00
parent 9258ebd8c7
commit 36ef41b710
No known key found for this signature in database
GPG Key ID: C5BAD04C77B91B4B
3 changed files with 46 additions and 47 deletions

View File

@ -1,47 +0,0 @@
name: Publish package to GitHub Packages
on:
release:
types: [created]
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt'
cache: gradle
- name: Get release
id: get_release
uses: bruceadams/get-release@v1.3.2
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1
- name: Publish package
uses: gradle/gradle-build-action@v2
with:
arguments: publish
env:
GITHUB_VERSION: ${{ steps.get_release.outputs.tag }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload release artifact
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.get_release.outputs.upload_url }}
asset_path: build/libs/Multiverse-Core-${{ steps.get_release.outputs.tag }}.jar
asset_name: Multiverse-Core-${{ steps.get_release.outputs.tag }}.jar
asset_content_type: application/java-archive

View File

@ -8,6 +8,24 @@ jobs:
release_on_push:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt'
cache: gradle
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1
- name: Test & Build
uses: gradle/gradle-build-action@v2
with:
arguments: clean build -x assemble -x shadowJar
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create release
uses: rymndhng/release-on-push-action@v0.27.0
env:
@ -17,3 +35,27 @@ jobs:
tag_prefix: v
release_name: "Release <RELEASE_VERSION>"
use_github_release_notes: true
- name: Get release
id: get_release
uses: bruceadams/get-release@v1.3.2
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Publish package
uses: gradle/gradle-build-action@v2
with:
arguments: publish
env:
GITHUB_VERSION: ${{ steps.get_release.outputs.tag }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload release artifact
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.get_release.outputs.upload_url }}
asset_path: build/libs/Multiverse-Core-${{ steps.get_release.outputs.tag }}.jar
asset_name: Multiverse-Core-${{ steps.get_release.outputs.tag }}.jar
asset_content_type: application/java-archive

View File

@ -132,6 +132,10 @@ processResources {
filesMatching('plugin.yml') {
expand props
}
// This task should never be skipped. The tests depend on this having been run but we want the new version number
// that is created after tests are run and before we run again to publish.
outputs.upToDateWhen { false }
}