From 7180c29bb32413561405bb389251de4b48c3f847 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Millon?= Date: Wed, 19 Aug 2020 11:15:12 +0200 Subject: [PATCH] ci: Add release GitHub workflow Using a "custom" way to create a releasing with multiple artifacts following this issue: - https://github.com/actions/upload-release-asset/issues/28#issuecomment-617208601 - https://github.com/hashicorp/terraform-provider-kubernetes-alpha/blob/6a94abdffa085bb3564fc3670979cd223045dd5b/.github/workflows/release_binaries.yaml --- .github/workflows/release.yml | 56 +++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..e2c0229 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,56 @@ +name: Publish release +on: + push: + tags: + - "[0-9]+.[0-9]+*" + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Setup java + uses: actions/setup-java@v1.4.1 + with: + java-version: 1.8 + - name: Check version not snapshot + run: | + PROJECT_VERSION=$(./gradlew -q printVersion | tail -n 1) + echo "Project version is $PROJECT_VERSION" + if [[ "$PROJECT_VERSION" == *"SNAPSHOT" ]]; then exit 1; fi + - name: Decrypt large secret + run: | + chmod +x ./.github/workflows/decrypt_secret.sh + ./.github/workflows/decrypt_secret.sh + env: + GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} + - name: Build + run: ./gradlew build + - name: Publish + run: ./gradlew publish -PossrhUrl="$PUBLISH_RELEASE_REPO_URL" -PossrhUsername="$PUBLISH_REPO_USERNAME" -PossrhPassword="$PUBLISH_REPO_PASSWORD" -Psigning.keyId="$GPG_KEY_ID" -Psigning.password="$GPG_PASSPHRASE" -Psigning.secretKeyRingFile="$SIGN_FILE_PATH" + env: + PUBLISH_RELEASE_REPO_URL: https://oss.sonatype.org/service/local/staging/deploy/maven2/ + PUBLISH_REPO_USERNAME: ${{ secrets.PUBLISH_REPO_USERNAME }} + PUBLISH_REPO_PASSWORD: ${{ secrets.PUBLISH_REPO_PASSWORD }} + GPG_KEY_ID: ${{ secrets.GPG_KEY_ID }} + GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} + SIGN_FILE_PATH: "${{ github.workspace }}/.github/workflows/jcv_sign.gpg" + - name: Create Github release + run: | + set -x + assets=() + for asset in ${JCV_CORE_ASSETS_FOLDER}; do + assets+=("-a" "$asset") + done + for asset in ${JCV_ASSERTJ_ASSETS_FOLDER}; do + assets+=("-a" "$asset") + done + for asset in ${JCV_HAMCREST_ASSETS_FOLDER}; do + assets+=("-a" "$asset") + done + hub release create --draft "${assets[@]}" -m "Release of ${{ github.ref }}" "${{ github.ref }}" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + JCV_CORE_ASSETS_FOLDER: "${{ github.workspace }}/jcv-core/build/libs/*" + JCV_ASSERTJ_ASSETS_FOLDER: "${{ github.workspace }}/jcv-assertj/build/libs/*" + JCV_HAMCREST_ASSETS_FOLDER: "${{ github.workspace }}/jcv-hamcrest/build/libs/*"