From 70de4227ce3ebc2f4345de1b24e6d19b2a1c5172 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Brunner?= Date: Tue, 3 May 2022 10:19:55 +0200 Subject: [PATCH] Publish to GitHub Package --- .github/workflows/main.yaml | 26 ++++++++++++++++++++++++-- .github/workflows/rebuild.yaml | 10 ++++++++++ build.gradle | 2 +- ci/config.yaml | 5 ----- publish/README.md | 4 +--- 5 files changed, 36 insertions(+), 11 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 8486688156..bc5842d6ac 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -17,6 +17,8 @@ jobs: steps: - uses: actions/checkout@v3 + with: + fetch-depth: 0 - name: Get tag id: tag2 @@ -37,8 +39,28 @@ jobs: - run: gpg --export-secret-keys --armor D121AF2DFA8E140688BD968930C9B913FD42EF13 > CI.asc if: env.HAS_SECRETS == 'HAS_SECRETS' + - id: tag + run: echo "##[set-output name=tag;]$(echo ${{ github.ref }}|sed 's%refs/tags/%%g')" + if: startsWith(github.ref, 'refs/tags/') + - run: sed --in-place 's/version = .*/version = "${{ steps.tag.outputs.tag }}"/g' build.gradle + if: startsWith(github.ref, 'refs/tags/') + + - id: last-tag + run: echo "##[set-output name=tag;]$(git describe --tags --abbrev=0)" + if: "!startsWith(github.ref, 'refs/tags/')" + - id: no-tag + run: echo "##[set-output name=nb;]$(git log --oneline ${{ steps.last-tag.outputs.tag }}..HEAD|wc -l)" + if: "!startsWith(github.ref, 'refs/tags/')" + - run: sed --in-place 's/version = .*/version = "${{ steps.last-tag.outputs.tag }}"/g' build.gradle + if: "!startsWith(github.ref, 'refs/tags/') && steps.no-tag.outputs.nb == 0" + - run: sed --in-place 's/version = .*/version = "${{ steps.last-tag.outputs.tag }}+${{ steps.no-tag.outputs.nb }}"/g' build.gradle + if: "!startsWith(github.ref, 'refs/tags/') && steps.no-tag.outputs.nb > 0" + - run: sed --in-place 's/version = .*/version = "SNAPSHOT"/g' build.gradle + if: "github.ref == 'refs/heads/master'" + - run: echo "enablePublishing=true" > gradle.properties if: env.HAS_SECRETS == 'HAS_SECRETS' + - run: git diff - run: echo "${HOME}/.local/bin" >> ${GITHUB_PATH} - run: python3 -m pip install --user --requirement=ci/requirements.txt @@ -104,11 +126,11 @@ jobs: - name: Publish run: c2cciutils-publish if: env.HAS_SECRETS == 'HAS_SECRETS' + - run: docker run --rm --env=GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} mapfish_print_builder bash -c 'gradle build && gradle publish' + if: ( startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/master' ) && env.HAS_SECRETS == 'HAS_SECRETS' - id: version run: echo "##[set-output name=version;]$(grep version build.gradle|sed "s/ \+version = .\(.*\)./\1/g")" - - id: tag - run: echo "##[set-output name=tag;]$(echo ${{ github.ref }}|sed 's%refs/tags/%%g')" - name: Create Release id: create_release uses: actions/create-release@v1 diff --git a/.github/workflows/rebuild.yaml b/.github/workflows/rebuild.yaml index c7a218830e..669d1c1490 100644 --- a/.github/workflows/rebuild.yaml +++ b/.github/workflows/rebuild.yaml @@ -43,7 +43,17 @@ jobs: - run: gpg --export-secret-keys --armor D121AF2DFA8E140688BD968930C9B913FD42EF13 > CI.asc + - id: last-tag + run: echo "##[set-output name=tag;]$(git describe --tags --abbrev=0)" + - id: no-tag + run: echo "##[set-output name=nb;]$(git log --oneline ${{ steps.last-tag.outputs.tag }}..HEAD|wc -l)" + - run: sed --in-place 's/version = .*/version = "${{ steps.last-tag.outputs.tag }}"/g' build.gradle + if: 'steps.no-tag.outputs.nb == 0' + - run: sed --in-place 's/version = .*/version = "${{ steps.last-tag.outputs.tag }}+${{ steps.no-tag.outputs.nb }}"/g' build.gradle + if: 'steps.no-tag.outputs.nb > 0' + - run: echo "enablePublishing=true" > gradle.properties + - run: git diff - run: echo "${HOME}/.local/bin" >> ${GITHUB_PATH} - run: python3 -m pip install --user --requirement=ci/requirements.txt diff --git a/build.gradle b/build.gradle index 30bfe1ca28..c44e9e9693 100644 --- a/build.gradle +++ b/build.gradle @@ -23,7 +23,7 @@ wrapper { allprojects { group = 'org.mapfish.print' - version = '3.29.0-SNAPSHOT' + version = '1.0.0' ext.spotbugsVersion = '4.6.0' apply plugin: 'org.owasp.dependencycheck' diff --git a/ci/config.yaml b/ci/config.yaml index 6b5a2ce433..5fbcec6cf6 100644 --- a/ci/config.yaml +++ b/ci/config.yaml @@ -1,8 +1,3 @@ -version: - tag_to_version_re: - - from: release/([0-9]+\.[0-9]+\.[0-9]+) - to: \1 - checks: required_workflows: audit.yaml: diff --git a/publish/README.md b/publish/README.md index 15f218a4bf..c9dd0e18f5 100644 --- a/publish/README.md +++ b/publish/README.md @@ -7,9 +7,7 @@ which is the staging repository for maven central. # Automated Process -1. Edit the root `build.gradle` to change the `allprojects/version` and commit that with a - `release/${version}` tag. -2. Push the commit and the tag to GitHub. +1. Create a `x.y.z` tag. ## Docker daily build