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/.github/workflows/semantic-pr.yml b/.github/workflows/semantic-pr.yml index 040787fea..0636f7402 100644 --- a/.github/workflows/semantic-pr.yml +++ b/.github/workflows/semantic-pr.yml @@ -34,6 +34,7 @@ jobs: revert style test + release scopes: | api diff --git a/Makefile b/Makefile index 9f19c6859..b90bfdc99 100644 --- a/Makefile +++ b/Makefile @@ -491,3 +491,12 @@ endif $(DIST_DIR)/CHANGELOG.md: $(ROOT_DIR)/cliff.toml bin/git-cliff | $(DIST_DIR) $(GITCLIFF_BIN) --config $(ROOT_DIR)/cliff.toml --output $@ $(GITCLIFF_OPTS) + +.PHONY: multimod-verify +multimod-verify: bin/multimod + @echo "Validating versions.yaml file" + $(MULTIMOD_BIN) verify + +.PHONY: multimod-prerelease +multimod-prerelease: bin/multimod + $(MULTIMOD_BIN) prerelease --all-module-sets --skip-go-mod-tidy=true --commit-to-different-branch=false diff --git a/RELEASE.md b/RELEASE.md new file mode 100644 index 000000000..172a4c4d5 --- /dev/null +++ b/RELEASE.md @@ -0,0 +1,68 @@ +# Release + +This document outlines the process for creating a new release for VMClarity using the [Go MultiMod Releaser](https://github.com/open-telemetry/opentelemetry-go-build-tools/tree/main/multimod). All code block examples provided below correspond to an update to version `v0.7.0`, please update accordingly. + +## 1. Update the New Release Version + +* Create a new branch for the release version update. +```sh +git checkout -b release/v0.7.0 +``` + +* Modify the `versions.yaml` file to update the version for VMClarity's module-set. Keep in mind that the same version is applied to all modules. +```diff + vmclarity: +- version: v0.6.0 ++ version: v0.7.0 +``` + +* Commit the changes with a suitable message. +```sh +git add versions.yaml +git commit -m "release: update module set to version v0.7.0" +``` + +* Run the version verification command to check for any issues. +```sh +make multimod-verify +``` + +## 2. Bump All Dependencies to the New Release Version + +* Run the following command to update all `go.mod` files to the new release version. +```sh +make multimod-prerelease +``` + +* Review the changes made in the last commit to ensure correctness. + +* Push the branch to the GitHub repository. +```sh +git push origin release/v0.7.0 +``` + +* Create a pull request for these changes with a title like "release: prepare version v0.7.0". + +## 3. Create and Push Tags + +* After the pull request is approved and merged, update your local main branch. +```sh +git checkout main +git pull origin main +``` + +* To trigger the release workflow, create and push to the repository a release tag for the last commit. +```sh +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. + +## 4. Publish release + +* Wait until the release workflow is completed successfully. + +* Navigate to the [Releases page](https://github.com/openclarity/vmclarity/releases) and verify the draft release description as well as the assets listed. + +* Once the draft release has been verified, click on `Edit` release and then on `Publish Release`. diff --git a/makefile.d/20-tools.mk b/makefile.d/20-tools.mk index 9b433516a..97d4f54b6 100644 --- a/makefile.d/20-tools.mk +++ b/makefile.d/20-tools.mk @@ -231,3 +231,16 @@ bin/typos-$(TYPOS_VERSION): | $(BIN_DIR) @curl -sSfL 'https://github.com/crate-ci/typos/releases/download/v$(TYPOS_VERSION)/typos-v$(TYPOS_VERSION)-$(TYPOS_ARCH)-$(TYPOS_OSTYPE).tar.gz' --output - \ | tar xzvOf - './typos' > $@ @chmod +x $@ + +#### +## Go MultiMod Releaser +#### + +MULTIMOD_VERSION := 0.13.0 +MULTIMOD_BIN := $(BIN_DIR)/multimod +MULTIMOD_REPO_DIR := $(BIN_DIR)/opentelemetry-go-build-tools + +bin/multimod: + @if [ ! -d $(MULTIMOD_REPO_DIR) ]; then git clone https://github.com/open-telemetry/opentelemetry-go-build-tools --branch multimod/v$(MULTIMOD_VERSION) $(MULTIMOD_REPO_DIR); fi + @go build -C $(MULTIMOD_REPO_DIR)/multimod -o $(MULTIMOD_BIN) main.go + @rm -rf $(MULTIMOD_REPO_DIR) diff --git a/versions.yaml b/versions.yaml new file mode 100644 index 000000000..ce40adcd3 --- /dev/null +++ b/versions.yaml @@ -0,0 +1,21 @@ +module-sets: + vmclarity: + version: v0.6.0 + modules: + - github.com/openclarity/vmclarity/uibackend/types + - github.com/openclarity/vmclarity/uibackend/server + - github.com/openclarity/vmclarity/uibackend/client + - github.com/openclarity/vmclarity/core + - github.com/openclarity/vmclarity/provider + - github.com/openclarity/vmclarity/utils + - github.com/openclarity/vmclarity/installation + - github.com/openclarity/vmclarity/cli + - github.com/openclarity/vmclarity/testenv + - github.com/openclarity/vmclarity/api/types + - github.com/openclarity/vmclarity/api/server + - github.com/openclarity/vmclarity/api/client + - github.com/openclarity/vmclarity/e2e + - github.com/openclarity/vmclarity/containerruntimediscovery/types + - github.com/openclarity/vmclarity/containerruntimediscovery/server + - github.com/openclarity/vmclarity/containerruntimediscovery/client + - github.com/openclarity/vmclarity/orchestrator