From c7f1d6ccda1002625b6d5ae79fe8aaa13100d13d Mon Sep 17 00:00:00 2001 From: Victor Ramperez Date: Tue, 10 Nov 2026 17:25:53 +0100 Subject: [PATCH] ci: work out and publish the versions with the shared workflows The pre-release and the release worked out the version with zwaldowski/match-label-action, zwaldowski/semver-release-action and actions-ecosystem/action-get-merged-pull-request, and published it, with the binaries, with marvinpinto/action-automatic-releases, which is archived. They now use semver-version.yml and github-release.yml of FIWARE/github-workflows: the label is read when the job runs, the pre-release of a pull request is replaced on every push, and a release is never replaced. A version given to the release workflow is still used as it is. A push to main whose pull request has no semver label now fails the release, as in the other FIWARE repositories, instead of being skipped silently. check.yml, which only checked the label, is removed: the pre-release checks it and asks for it. Unlike pull_request_target, it cannot comment on a pull request from a fork, but the check still fails there. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/check.yml | 43 --------------- .github/workflows/pre-release.yml | 61 +++++++------------- .github/workflows/release.yml | 92 +++++++++++-------------------- 3 files changed, 52 insertions(+), 144 deletions(-) delete mode 100644 .github/workflows/check.yml diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml deleted file mode 100644 index 1bb0681a..00000000 --- a/.github/workflows/check.yml +++ /dev/null @@ -1,43 +0,0 @@ -name: Check PR - -on: - pull_request_target: - types: - - opened - - synchronize - - reopened - - labeled - - unlabeled - branches: - - main - -concurrency: - group: check-${{ github.event.pull_request.number }} - cancel-in-progress: true - -permissions: - pull-requests: write - -jobs: - check: - runs-on: ubuntu-latest - steps: - - id: bump - uses: zwaldowski/match-label-action@v1 - with: - allowed: major,minor,patch - - - uses: zwaldowski/semver-release-action@v6 - with: - dry_run: true - bump: ${{ steps.bump.outputs.match }} - github_token: ${{ secrets.GITHUB_TOKEN }} - - comment: - needs: check - runs-on: ubuntu-latest - if: failure() - steps: - - uses: thollander/actions-comment-pull-request@v3 - with: - message: "Please apply one of the following labels to the PR: `patch`, `minor`, or `major`. See [CONTRIBUTING.md](https://github.com/${{ github.repository }}/blob/main/CONTRIBUTING.md) for details." diff --git a/.github/workflows/pre-release.yml b/.github/workflows/pre-release.yml index ea5a780e..5dd1772c 100644 --- a/.github/workflows/pre-release.yml +++ b/.github/workflows/pre-release.yml @@ -21,29 +21,15 @@ env: IMAGE_NAME: vcverifier jobs: + # The version from the semver label of the pull request, read when the job runs. See + # https://github.com/FIWARE/github-workflows generate-version: - runs-on: ubuntu-latest - outputs: - version: ${{ steps.out.outputs.version }} - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - id: bump - uses: zwaldowski/match-label-action@v1 - with: - allowed: major,minor,patch - - - uses: zwaldowski/semver-release-action@v6 - with: - dry_run: true - bump: ${{ steps.bump.outputs.match }} - github_token: ${{ secrets.GITHUB_TOKEN }} - - - name: Set pre-release version - id: out - run: echo "version=${VERSION}-PRE-${{ github.event.pull_request.number }}" >> $GITHUB_OUTPUT + uses: FIWARE/github-workflows/.github/workflows/semver-version.yml@v1 + permissions: + contents: read + pull-requests: write + with: + tag-prefix: "" build-scan-push: needs: generate-version @@ -131,29 +117,20 @@ jobs: path: vcverifier-${{ matrix.goos }}-${{ matrix.goarch }} retention-days: 1 + # Publishes the pre-release, replacing the one of the previous push, see + # https://github.com/FIWARE/github-workflows git-release: - needs: + needs: - generate-version - build-scan-push - build-binaries - runs-on: ubuntu-latest + uses: FIWARE/github-workflows/.github/workflows/github-release.yml@v1 permissions: contents: write - steps: - - uses: actions/checkout@v4 - - - uses: actions/download-artifact@v4 - with: - path: release-assets - pattern: vcverifier-* - merge-multiple: true - - - uses: marvinpinto/action-automatic-releases@latest - with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - automatic_release_tag: ${{ needs.generate-version.outputs.version }} - prerelease: true - title: ${{ needs.generate-version.outputs.version }} - files: | - LICENSE - release-assets/vcverifier-* + with: + version: ${{ needs.generate-version.outputs.version }} + prerelease: true + files: | + LICENSE + release-assets/vcverifier-* + artifact-pattern: vcverifier-* diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d77638b7..c3fdd925 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,55 +19,39 @@ env: IMAGE_NAME: vcverifier jobs: + # The version from the semver label of the merged pull request; a push without one fails, as in + # the other FIWARE repositories. See https://github.com/FIWARE/github-workflows + semver: + if: inputs.version == '' + uses: FIWARE/github-workflows/.github/workflows/semver-version.yml@v1 + permissions: + contents: read + pull-requests: write + with: + tag-prefix: "" + + # The version given by the caller, or the one from the label generate-version: + needs: semver + if: ${{ !cancelled() && (needs.semver.result == 'success' || needs.semver.result == 'skipped') }} runs-on: ubuntu-latest outputs: version: ${{ steps.version.outputs.version }} has_version: ${{ steps.version.outputs.has_version }} steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - id: pr - if: inputs.version == '' - uses: actions-ecosystem/action-get-merged-pull-request@v1.0.1 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - - - name: Detect semver label - if: inputs.version == '' - id: label - run: | - BUMP="" - while IFS= read -r label; do - case "$label" in - major|minor|patch) BUMP="$label"; break ;; - esac - done <<< "${{ steps.pr.outputs.labels }}" - echo "bump=$BUMP" >> $GITHUB_OUTPUT - [[ -n "$BUMP" ]] && echo "has_bump=true" >> $GITHUB_OUTPUT || echo "has_bump=false" >> $GITHUB_OUTPUT - - - uses: zwaldowski/semver-release-action@v6 - if: inputs.version == '' && steps.label.outputs.has_bump == 'true' - id: semver - with: - dry_run: true - bump: ${{ steps.label.outputs.bump }} - github_token: ${{ secrets.GITHUB_TOKEN }} - - name: Set version output id: version + env: + INPUT_VERSION: ${{ inputs.version }} + SEMVER_VERSION: ${{ needs.semver.outputs.version }} run: | - if [[ -n "${{ inputs.version }}" ]]; then - echo "version=${{ inputs.version }}" >> $GITHUB_OUTPUT - echo "has_version=true" >> $GITHUB_OUTPUT - elif [[ "${{ steps.label.outputs.has_bump }}" == "true" ]]; then - echo "version=${{ steps.semver.outputs.version }}" >> $GITHUB_OUTPUT - echo "has_version=true" >> $GITHUB_OUTPUT - else - echo "has_version=false" >> $GITHUB_OUTPUT - fi + version="${INPUT_VERSION:-$SEMVER_VERSION}" + if [ -n "$version" ]; then has_version=true; else has_version=false; fi + { + echo "version=$version" + echo "has_version=$has_version" + } >> "$GITHUB_OUTPUT" + echo "Version: $version" build-scan-push: needs: generate-version @@ -161,30 +145,20 @@ jobs: path: vcverifier-${{ matrix.goos }}-${{ matrix.goarch }} retention-days: 1 + # Publishes the release, with the binaries, see https://github.com/FIWARE/github-workflows git-release: needs: - generate-version - build-scan-push - build-binaries if: needs.generate-version.outputs.has_version == 'true' - runs-on: ubuntu-latest + uses: FIWARE/github-workflows/.github/workflows/github-release.yml@v1 permissions: contents: write - steps: - - uses: actions/checkout@v4 - - - uses: actions/download-artifact@v4 - with: - path: release-assets - pattern: vcverifier-* - merge-multiple: true - - - uses: marvinpinto/action-automatic-releases@latest - with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - automatic_release_tag: ${{ needs.generate-version.outputs.version }} - prerelease: false - title: ${{ needs.generate-version.outputs.version }} - files: | - LICENSE - release-assets/vcverifier-* + with: + version: ${{ needs.generate-version.outputs.version }} + prerelease: false + files: | + LICENSE + release-assets/vcverifier-* + artifact-pattern: vcverifier-*