Skip to content
This repository was archived by the owner on Oct 14, 2024. It is now read-only.

Commit

Permalink
feat: add release for multiple modules (#1276)
Browse files Browse the repository at this point in the history
* feat: create module set for release with all modules

* feat: build multimod

* feat: add multimod verify and prerelease

* feat: add create and push tags

* docs: improve release instructions

* refactor: code review

* feat: create module tags once release is published

* docs: improve release instructions

* release: pin multimod version

* refactor: clone with https

Co-authored-by: Ramiz Polic <[email protected]>

---------

Co-authored-by: Ramiz Polic <[email protected]>
  • Loading branch information
paralta and ramizpolic authored Mar 12, 2024
1 parent 85a84b9 commit 18a837a
Show file tree
Hide file tree
Showing 7 changed files with 156 additions and 22 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/post-release.yaml
Original file line number Diff line number Diff line change
@@ -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
})
22 changes: 0 additions & 22 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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/<version>" 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 }}
1 change: 1 addition & 0 deletions .github/workflows/semantic-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ jobs:
revert
style
test
release
scopes: |
api
Expand Down
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -496,3 +496,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
68 changes: 68 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -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`.
13 changes: 13 additions & 0 deletions makefile.d/20-tools.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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)
21 changes: 21 additions & 0 deletions versions.yaml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 18a837a

Please sign in to comment.