diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..43fafd1 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,42 @@ +name: Build + +on: + push: + branches: + - '**' + tags-ignore: + - 'v*.*' + workflow_call: + inputs: + version: + type: string + +jobs: + build: + name: Gradle build + runs-on: ubuntu-latest + steps: + - id: version + name: Detect version + run: echo "version=${VERSION:-1.0+git-${GITHUB_SHA::7}}" >> $GITHUB_OUTPUT + env: + VERSION: ${{ inputs.version }} + - name: Checkout + uses: actions/checkout@v3 + - uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + - name: Validate Gradle wrapper + uses: gradle/wrapper-validation-action@v1 + - name: Build + uses: gradle/gradle-build-action@v2 + with: + arguments: | + build + -Pversion=${{ steps.version.outputs.version }} + - name: Upload artifacts + uses: actions/upload-artifact@v3 + with: + name: gradle-build + path: build/libs/*-all.jar diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..c10c8be --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,47 @@ +name: GitHub release + +on: + push: + tags: + - 'v*.*' + +permissions: + contents: write + +jobs: + version: + name: Extract version from git + runs-on: ubuntu-latest + outputs: + version: ${{ steps.version.outputs.version }} + steps: + - id: version + name: Extract version + run: | + TAG=${{ github.ref }} + VERSION=${TAG#refs/tags/v} + echo "version=$VERSION" >> $GITHUB_OUTPUT + build: + name: Build + needs: version + uses: ./.github/workflows/build.yml + with: + version: ${{ needs.version.outputs.version }} + release: + name: Prepare release + needs: + - version + - build + runs-on: ubuntu-latest + steps: + - name: Download build artifacts + uses: actions/download-artifact@v3 + with: + name: gradle-build + - name: Create GitHub release + uses: softprops/action-gh-release@v1 + with: + name: ${{ needs.version.outputs.version }} + generate_release_notes: true + draft: true + files: '*' \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index 3848553..4b554d1 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -5,7 +5,6 @@ plugins { } group = "info.mmpa" -version = "1.0-SNAPSHOT" repositories { mavenCentral() diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..26969d4 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,3 @@ +# Default development version +# See: ./.github/workflows/build.yml +version=1.0-SNAPSHOT