diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..ef4cafb --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,68 @@ +name: Build and release + +on: + workflow_dispatch: + inputs: + release_made: + description: "I have update the release/RELEASE.md file to describe the release." + required: true + type: boolean + +jobs: + check_release: + name: Check input parameters + if: ${{ !inputs.release_made }} + runs-on: ubuntu-latest + steps: + - run: echo "Release check wasn't checked" + build: + name: 🏗️ Building project + if: ${{ inputs.release_made }} + runs-on: ubuntu-latest + outputs: + version: ${{ steps.version_get.outputs.version }} + steps: + - uses: actions/checkout@v2 + - name: 🗝️ update permissions + run: chmod u+x gradlew + - name: ⚙️ get version + id: version_get + run: echo "::set-output name=version::$(scripts/get_version.sh)" + - name: ⚙️ Set up JDK + uses: actions/setup-java@v1 + with: + java-version: 17 + - name: 🏗️ Compile wiki-changes + run: ./gradlew shadowJar + - name: ⚙️ Move compiled jar + run: mv ./build/libs/wikidata-changes-*-all.jar wiki-changes.jar + - name: ☁️ Upload artifact + uses: actions/upload-artifact@v3 + with: + name: "wiki-changes.jar" + path: "wiki-changes.jar" + create_release: + name: 🚀 Create Github release + environment: + name: release + url: "https://github.com/the-qa-company/wiki-changes/releases/tag/v${{ needs.build.outputs.version }}" + needs: + - build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: ☁️ Download artifacts + uses: actions/download-artifact@v3 + - name: ⚙️ Extract artifacts + run: | + mkdir -p deploy_file + mv wiki-changes.jar/* deploy_file + - name: 🚀 Create release with artifacts + uses: ncipollo/release-action@v1 + with: + commit: ${{ github.sha }} + tag: "v${{ needs.build.outputs.version }}" + artifacts: "deploy_file/*" + name: "Release ${{ needs.build.outputs.version }}" + bodyFile: "release/RELEASE.md" + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/build.gradle b/build.gradle index ecca43d..eabf28f 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ plugins { } group 'com.the-qa-company' -version '0.1-SNAPSHOT' +version '0.1.0-SNAPSHOT' repositories { mavenCentral() @@ -39,3 +39,9 @@ dependencies { test { useJUnitPlatform() } + +tasks.register("printVersion") { + doLast { + println(rootProject.version) + } +} \ No newline at end of file diff --git a/release/RELEASE.md b/release/RELEASE.md new file mode 100644 index 0000000..ed00e93 --- /dev/null +++ b/release/RELEASE.md @@ -0,0 +1,3 @@ +**Changelog 📓** + +- Release wiki-changes.jar diff --git a/scripts/get_version.sh b/scripts/get_version.sh new file mode 100755 index 0000000..de4ff9d --- /dev/null +++ b/scripts/get_version.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +BASE=`dirname $0` + +cd $BASE/.. + +./gradlew printVersion -q \ No newline at end of file