From 2c96a5343240e75b8bae726f55f1b6a5fe3a7366 Mon Sep 17 00:00:00 2001 From: Catarina Paralta <46568597+paralta@users.noreply.github.com> Date: Tue, 27 Feb 2024 14:21:03 +0000 Subject: [PATCH] feat: create module tags once release is published --- .github/workflows/post-release.yaml | 44 +++++++++++++++++++++++++++++ .github/workflows/release.yaml | 22 --------------- Makefile | 7 ----- RELEASE.md | 9 ++++-- 4 files changed, 50 insertions(+), 32 deletions(-) create mode 100644 .github/workflows/post-release.yaml diff --git a/.github/workflows/post-release.yaml b/.github/workflows/post-release.yaml new file mode 100644 index 000000000..b903783f5 --- /dev/null +++ b/.github/workflows/post-release.yaml @@ -0,0 +1,44 @@ +name: Post Release +on: + release: + types: [published] + +jobs: + prepare: + name: Prepare + runs-on: ubuntu-latest + outputs: + modules: ${{ steps.modules.outputs.modules }} + steps: + - name: Checkout + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + + - name: Get modules + id: modules + run: | + # shellcheck disable=SC2016 + echo "modules=$(find . -name go.mod -type f -print0 | xargs -0 awk '/module/ {print $2}' | jq -c -R '[.,inputs] | map(sub("^github.com\/openclarity\/vmclarity\/";""))')" >> "$GITHUB_OUTPUT" + + create_module_tags: + needs: + - prepare + name: Create module tags + runs-on: ubuntu-latest + strategy: + matrix: + tags: ${{ fromJson(needs.prepare.outputs.modules) }} + steps: + - name: Checkout + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + + - name: Create tags + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + github.rest.git.createRef({ + owner: context.repo.owner, + repo: context.repo.repo, + ref: 'refs/tags/${{ matrix.tags }}/${{ github.ref_name }}', + sha: context.sha + }) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index b97757366..0ce7b00ce 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -151,25 +151,3 @@ jobs: draft: true name: "Release ${{ github.ref_name }}" updateOnlyUnreleased: true - - # TODO(sambetts) We need to publish a tag in the format "api/" tag - # so that go mod is able to import the api module without overriding. We need - # to work out how to do this cleanly from github actions on release so that - # we don't need to manage it manually. We could do something this which will - # create another release: - # - # api_release: - # needs: release - # name: Release API Module - # runs-on: ubuntu-latest - # steps: - # - name: Checkout - # uses: actions/checkout@v4 - # with: - # fetch-depth: 0 - # - name: Release API - # uses: softprops/action-gh-release@v1 - # with: - # name: VMClarity {{ github.ref }} API - # body: See main {{ github.ref }} release for release notes. - # tag_name: api/{{ github.ref }} diff --git a/Makefile b/Makefile index 9f11e5326..b90bfdc99 100644 --- a/Makefile +++ b/Makefile @@ -500,10 +500,3 @@ multimod-verify: bin/multimod .PHONY: multimod-prerelease multimod-prerelease: bin/multimod $(MULTIMOD_BIN) prerelease --all-module-sets --skip-go-mod-tidy=true --commit-to-different-branch=false - -.PHONY: multimod-push-tags -multimod-push-tags: bin/multimod - set -e; for tag in `$(MULTIMOD_BIN) tag --module-set-name vmclarity --commit-hash HEAD --print-tags | grep -v "Using" `; do \ - echo "pushing tag $${tag}"; \ - git push origin $${tag}; \ - done; diff --git a/RELEASE.md b/RELEASE.md index 48fa8e00c..4e42e7ebb 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -41,7 +41,7 @@ make multimod-prerelease git push origin release/v0.7.0 ``` -* Create a pull request with the changes. +* Create a pull request for these changes with a title like "release: prepare version v0.7.0". ## 3. Create and Push Tags @@ -51,11 +51,14 @@ git checkout main git pull origin main ``` -* Create and push the tags for the last commit to the repository. +* To trigger the release workflow, create and push to the repository a release tag for the last commit. ```sh -make multimod-push-tags +git tag -a v0.7.0 +git push origin v0.7.0 ``` +Please note that the release tag is not necessarily associated with the "release: prepare version v0.7.0" commit. For example, if any bug fixes were required after this commit, they can be merged and included in the release. + ## Post-release Checks Verify that the `Release` workflow was completed successfully in the GitHub Actions section. Ensure that the release is visible in the GitHub releases page. Additionally, check that the release description is correct and all assets are listed.