diff --git a/.dockerignore b/.dockerignore index ba8f5ffed7..fc54fb0a69 100644 --- a/.dockerignore +++ b/.dockerignore @@ -22,6 +22,7 @@ bin /hack /LICENSES /local +/gen /pkg/test* @@ -35,3 +36,4 @@ bin !go.* !**/*.go +!.git \ No newline at end of file diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index ce831abcda..1b1d6f773c 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -3,6 +3,10 @@ # will be requested for review when someone opens a pull request. * @open-component-model/Maintainers +# Changes on repository settings require admin permissions +/.github/settings.yml @open-component-model/admins +/.github/CODEOWNERS @open-component-model/admins + # Owners for specific directories #/docs/ @/ #/src/ @/ diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 99fcd655f1..beb023a9ab 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -1,7 +1,7 @@ --- name: Bug Report about: Report a bug -labels: kind/bug +labels: kind/bugfix --- diff --git a/.github/ISSUE_TEMPLATE/enhancement_request.md b/.github/ISSUE_TEMPLATE/enhancement_request.md index 84a7d6c8f0..4bbaa79c0b 100644 --- a/.github/ISSUE_TEMPLATE/enhancement_request.md +++ b/.github/ISSUE_TEMPLATE/enhancement_request.md @@ -1,7 +1,7 @@ --- name: Enhancement Request about: Suggest an enhancement -labels: kind/enhancement +labels: kind/feature --- diff --git a/.github/ISSUE_TEMPLATE/user_story.md b/.github/ISSUE_TEMPLATE/user_story.md index 645631eefa..7778433c9d 100644 --- a/.github/ISSUE_TEMPLATE/user_story.md +++ b/.github/ISSUE_TEMPLATE/user_story.md @@ -1,7 +1,7 @@ --- name: User Story about: User Story -labels: +labels: kind/feature title: - Title --- diff --git a/.github/config/labeler.yml b/.github/config/labeler.yml index 2efa435e4a..a1177b0253 100644 --- a/.github/config/labeler.yml +++ b/.github/config/labeler.yml @@ -1,9 +1,27 @@ # see https://github.com/actions/labeler?tab=readme-ov-file#match-object to configure correctly -dependencies: +kind/dependency: - any: - head-branch: 'dependencies/*' - head-branch: 'dependabot/*' -github-actions: + - changed-files: + - any-glob-to-any-file: ['go.mod', 'go.sum'] +component/github-actions: +- any: + - changed-files: + - any-glob-to-any-file: ['.github/**'] +area/documentation: +- any: + - changed-files: + - any-glob-to-any-file: ['docs/**', 'examples/**'] +component/ocm-cli: +- any: + - changed-files: + - any-glob-to-any-file: ['components/ocmcli/**', 'cmds/ocm/**'] +component/ocm-spec: +- any: + - changed-files: + - any-glob-to-any-file: ['resources/**'] +kind/skip-release-notes: - any: - changed-files: - - any-glob-to-any-file: ['.github/**'] \ No newline at end of file + - any-glob-to-any-file: ['flake.lock', 'flake.nix'] diff --git a/.github/config/markdown-link-check.json b/.github/config/markdown-link-check.json index 9f14fd321d..89c303a8b9 100644 --- a/.github/config/markdown-link-check.json +++ b/.github/config/markdown-link-check.json @@ -5,5 +5,6 @@ { "pattern": "^http[s]*://localhost.*" } ,{ "pattern": "^https://.*\\.sigstore\\.dev.*" } ,{ "pattern": "^{{.*}}$" } + ,{ "pattern": "^https://github.com/**/compare/**" } ] } diff --git a/.github/config/markdownignore b/.github/config/markdownignore index 61874c2a7a..00158608b8 100644 --- a/.github/config/markdownignore +++ b/.github/config/markdownignore @@ -1,3 +1,4 @@ examples/lib/tour/0* docs/reference docs/pluginreference +hack/collapse/* \ No newline at end of file diff --git a/.github/config/release.yml b/.github/config/release.yml new file mode 100644 index 0000000000..b3eec8b0fd --- /dev/null +++ b/.github/config/release.yml @@ -0,0 +1,30 @@ +changelog: + # ../workflows/pull_request.yaml#verify-labels one_of: kind/chore,kind/bugfix,kind/feature,kind/dependency,kind/refactor + exclude: + labels: + - 'kind/skip-release-notes' + - 'dev/wont-fix' + - 'dev/cant-reproduce' + # if an issue matches more than one category, the first one in the list will be used + # Example: + # Labels: kind/chore, kind/dependency => Category: Dependencies + categories: + - title: '‼️ Breaking Changes' + labels: + - '!BREAKING-CHANGE!' + - title: '🚀 Features' + labels: + - 'kind/feature' + - title: '🐛 Bug Fixes' + labels: + - 'kind/bugfix' + - title: '⬆️ Dependencies' + labels: + - 'kind/dependency' + - title: '🧰 Maintenance' + labels: + - 'kind/chore' + - 'kind/refactor' + - title: 'Other Changes' + labels: + - "*" diff --git a/.github/config/wordlist.txt b/.github/config/wordlist.txt index 81e7bd3d34..d38b0d4469 100644 --- a/.github/config/wordlist.txt +++ b/.github/config/wordlist.txt @@ -27,6 +27,7 @@ bool boolean buildx cas +changelog chocolateyinstall cli cliconfig @@ -215,6 +216,7 @@ packageversion parameterization pendingdeprecationwarning pflag +pkgs podinfo podman pre @@ -239,6 +241,7 @@ resendbuffer resmgmt resolvers resourcereference +retrigger routings routingslips rsa @@ -305,4 +308,4 @@ xml yaml yitsushi yml -yyyy +yyyy \ No newline at end of file diff --git a/.github/dependabot.yml b/.github/dependabot.yml index f689040921..6a4c244582 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -11,6 +11,11 @@ updates: schedule: interval: "weekly" day: "sunday" + labels: + - kind/dependency + - kind/chore + - kind/skip-release-notes + - component/github-actions - package-ecosystem: "gomod" directory: "/" groups: @@ -19,3 +24,14 @@ updates: schedule: interval: "weekly" day: "sunday" + labels: + - kind/dependency + - kind/chore + - package-ecosystem: docker + directory: "/" + schedule: + interval: "weekly" + day: "sunday" + labels: + - kind/dependency + - kind/chore diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml deleted file mode 100644 index 6827c023ff..0000000000 --- a/.github/release-drafter.yml +++ /dev/null @@ -1,38 +0,0 @@ -name-template: 'v$RESOLVED_VERSION' -tag-template: 'v$RESOLVED_VERSION' -version-template: '$COMPLETE' -change-template: '- $TITLE (#$NUMBER)' -change-title-escapes: '\<*_&#@`' -template: | - # Release v$RESOLVED_VERSION - - $CHANGES -exclude-labels: - - 'kind/skip-release-notes' - - 'wontfix' - - 'triage/wont-fix' - - 'triage/invalid' -categories: - - title: '‼️ Breaking Changes' - labels: - - 'breaking-change' - - title: '🚀 Features' - labels: - - 'kind/enhancement' - - 'feature' - - 'enhancement' - - title: '🐛 Bug Fixes' - collapse-after: 5 - labels: - - 'kind/bug' - - 'fix' - - 'bugfix' - - 'bug' - - title: '🧰 Maintenance' - collapse-after: 3 - labels: - - 'chore' - - title: '⬆️ Dependencies' - collapse-after: 3 - labels: - - 'dependencies' diff --git a/.github/settings.yml b/.github/settings.yml new file mode 100644 index 0000000000..53861cbcc7 --- /dev/null +++ b/.github/settings.yml @@ -0,0 +1,8 @@ +# These settings are synced to GitHub by https://probot.github.io/apps/settings/ + +# see: https://github.com/open-component-model/.github/blob/main/.github/settings.yml +_extends: .github + +labels: +- name: repo/ocm + color: bfd4f2 diff --git a/.github/workflows/components.yaml b/.github/workflows/components.yaml index c519473c20..c6f8d53bde 100644 --- a/.github/workflows/components.yaml +++ b/.github/workflows/components.yaml @@ -33,6 +33,8 @@ env: components: '["ocmcli", "helminstaller", "helmdemo", "subchartsdemo", "ecrplugin"]' IMAGE_PLATFORMS: 'linux/amd64 linux/arm64' PLATFORMS: 'windows/amd64 darwin/arm64 darwin/amd64 linux/amd64 linux/arm64' + BUILDX_CACHE_PUSH: false + BUILDX_CACHE_REF_BASE: ghcr.io/${{ github.repository }}/buildx-cache jobs: define-matrix: @@ -66,6 +68,14 @@ jobs: with: go-version-file: '${{ github.workspace }}/go.mod' cache: false + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Docker Login + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - name: Get go environment for use with cache run: | echo "go_cache=$(go env GOCACHE)" >> $GITHUB_ENV @@ -95,6 +105,8 @@ jobs: VERSION=${{ inputs.version }} \ PLATFORMS="${{ env.PLATFORMS }}" \ IMAGE_PLATFORMS="${{ env.IMAGE_PLATFORMS }}" \ + BUILDX_CACHE_REF=${{ env.BUILDX_CACHE_REF_BASE }}:${{ matrix.component }} \ + BUILDX_CACHE_PUSH=${{ env.BUILDX_CACHE_PUSH }} \ make \ ctf descriptor describe - name: Upload CTF diff --git a/.github/workflows/flake_vendorhash.yaml b/.github/workflows/flake_vendorhash.yaml index 4e4c390cb8..b1d20d21ee 100644 --- a/.github/workflows/flake_vendorhash.yaml +++ b/.github/workflows/flake_vendorhash.yaml @@ -59,6 +59,6 @@ jobs: sign-commits: true labels: | kind/skip-release-notes - chore + kind/chore body: | Update OCM CLI vendor hash (see: .github/workflows/flake_vendorhash.yaml) diff --git a/.github/workflows/pull-request.yaml b/.github/workflows/pull-request.yaml index 06785945db..921f37fe87 100644 --- a/.github/workflows/pull-request.yaml +++ b/.github/workflows/pull-request.yaml @@ -24,18 +24,18 @@ jobs: env: TYPE_TO_LABEL: | { - "feat":"kind/enhancement", - "fix":"fix", - "chore":"chore", - "docs":"kind/documentation", - "test":"kind/test", - "perf":"kind/performance" + "feat":"kind/feature", + "fix":"kind/bugfix", + "chore":"kind/chore", + "docs":"area/documentation", + "test":"area/testing", + "perf":"area/performance" } SCOPE_TO_LABEL: | { - "deps":"dependencies" + "deps":"kind/dependency" } - BREAKING_CHANGE_LABEL: "breaking" + BREAKING_CHANGE_LABEL: "!BREAKING-CHANGE!" with: script: | console.log("Verify that the PR title follows the Conventional Commit format"); @@ -158,5 +158,5 @@ jobs: - name: PRs should have at least one qualifying label uses: docker://agilepathway/pull-request-label-checker:latest with: - one_of: chore,fix,bugfix,bug,kind/bug,feature,enhancement,kind/enhancement,dependencies - repo_token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + any_of: kind/chore,kind/bugfix,kind/feature,kind/dependency,kind/refactor + repo_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release-branch.yaml b/.github/workflows/release-branch.yaml index f63d279c5f..237c8866cc 100644 --- a/.github/workflows/release-branch.yaml +++ b/.github/workflows/release-branch.yaml @@ -80,7 +80,19 @@ jobs: ref: main fetch-depth: 0 token: ${{ steps.generate_token.outputs.token }} - + - name: Setup git config + run: | + git config user.name "GitHub Actions Bot" + git config user.email "<41898282+github-actions[bot]@users.noreply.github.com>" + # tag the cutoff point in main so that it can be used for release note generation + - name: Create Cutoff Tag in Main + run: | + set -e + tag="v${{ needs.cutoff-preconditions.outputs.minor }}" + msg="Cutoff for $tag" + git tag --annotate --message "${msg}" "$tag" + git push origin "$tag" + # create a new branch - name: Create Release Branch run: | set -e diff --git a/.github/workflows/release-drafter.yaml b/.github/workflows/release-drafter.yaml index 607cf7613b..0566b2f353 100644 --- a/.github/workflows/release-drafter.yaml +++ b/.github/workflows/release-drafter.yaml @@ -11,7 +11,7 @@ on: permissions: contents: read # The release-drafter action adds PR titles to the release notes once these are merged to main. - # A draft release is kept up-to-date listing the changes for the next minor release version. + # A draft release is kept up-to-date listing the changes for the next minor or patch release version for that branch. jobs: release-version: name: Release Version @@ -31,12 +31,83 @@ jobs: env: RELEASE_VERSION: ${{ needs.release-version.outputs.version }} steps: + - name: Generate token + id: generate_token + uses: tibdex/github-app-token@v2 + with: + app_id: ${{ secrets.OCMBOT_APP_ID }} + private_key: ${{ secrets.OCMBOT_PRIV_KEY }} - name: Checkout uses: actions/checkout@v4 - - name: Drafter - uses: release-drafter/release-drafter@v6 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - tag: ${{env.RELEASE_VERSION }} - version: ${{env.RELEASE_VERSION }} \ No newline at end of file + fetch-depth: 0 + fetch-tags: true + - name: Setup Release with gh + env: + COLLAPSE_THRESHOLD: 5 + REF: ${{ github.ref }} + REPO: ${{ github.repository }} + GH_TOKEN: ${{ steps.generate_token.outputs.token }} + run: | + # generate the release notes based on the last previous tag. + # match only a valid semver tag. + # also do not match for the cutoff tag for the release branch. + # Example: If we are in releases/v0.18, we don't want to match v0.18 as the cutoff tag. + # Instead we want to match the one before that, which would be v0.17. + # That would generate us the notes from + # v0.17 to HEAD, which is what we want. + # + # Implementors Note: + # ##*\/ removes everything before the last / in the ref, + # e.g. refs/heads/releases/v0.18 -> v0.18 + previous_tag=$(git describe HEAD --abbrev=0 --tags --match "v*" --exclude "${REF##*\/}") + + if [[ -z $previous_tag ]]; then + echo "No previous tag found, cannot generate release notes" + exit 1 + fi + + echo "Generating release notes for ${{env.RELEASE_VERSION}} starting from ${previous_tag} to HEAD" + + notes=$(\ + gh api \ + --method POST \ + -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + /repos/${REPO}/releases/generate-notes \ + -f "tag_name=${{env.RELEASE_VERSION}}" \ + -f "target_commitish=${{ github.ref }}" \ + -f "previous_tag_name=${previous_tag}" \ + -f "configuration_file_path=.github/config/release.yml" \ + -q .body \ + ) + + if [[ -z "${notes}" ]]; then + echo "No release notes generated from API, failed" + exit 1 + fi + + echo "Auto-Collapsing release notes to reduce size" + echo "${notes}" > $RUNNER_TEMP/release_notes.md + bash hack/collapse/auto_collapse.sh $RUNNER_TEMP/release_notes.md $RUNNER_TEMP/release_notes_processed.md ${{ env.COLLAPSE_THRESHOLD }} + notes=$(cat $RUNNER_TEMP/release_notes_processed.md) + + echo "Release Notes generated for ${{env.RELEASE_VERSION}}:" + echo "${notes}" + + echo "Verifying if release ${{env.RELEASE_VERSION}} already exists" + if [[ -z $(gh release list -R ${REPO} --json name -q '.[] | select(.name == "${{env.RELEASE_VERSION}}")') ]]; then + echo "Release ${{env.RELEASE_VERSION}} does not exist yet, creating from scratch" + gh release create ${{env.RELEASE_VERSION}} \ + --title "${{env.RELEASE_VERSION}}" \ + --notes "${notes}" \ + --draft \ + --latest=false \ + --target ${{ github.ref }} \ + -R ${REPO} + else + echo "Release ${{env.RELEASE_VERSION}} already exists, updating existing..." + gh release edit ${{env.RELEASE_VERSION}} \ + --notes "${notes}" \ + -R ${REPO} + fi diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index f15bdb2250..b6034f388a 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -181,8 +181,27 @@ jobs: git commit -m "Release $RELEASE_VERSION" msg="Release ${{ env.RELEASE_VERSION }}" git tag --annotate --message "${msg}" ${{ env.RELEASE_VERSION }} - # push both the tag as well as a release branch with that tag. + # push the tag. git push origin ${{ env.RELEASE_VERSION }} + # If we encounter a release (i.e. NOT a candidate), we want to keep the tag in the release branch git history + # by merging it (without taking over its contents). + # This allows tools that rely on the latest tag (such as Release Note generators or git describe) + # to recognize the release as the latest version. + # We can then use this to generate release notes based on the previous tag. + # If we previously built a release candidate, the tag is not merged back. + # That results in the tag being "omitted" / not recognized while generating release notes. + # This is intended, because a candidate should never influence further release notes. + # Example: + # Branch releases/v0.19 + # - Candidate Build v0.19.0-rc.1 => no merge, release notes based on original cutoff + # - Actual Build v0.19.0 => merge, release notes based on original cutoff + # - Candidate Build v0.19.1-rc.1 => no merge, release notes based on v0.19.0 due to previous merge + - name: Merge Release Tag back into release branch if not a release candidate + if: inputs.release_candidate == false + run: | + git checkout ${{ github.ref }} + git merge --strategy ours ${{ env.RELEASE_VERSION }} + git push origin ${{ github.ref }} - name: Create GPG Token file from Secret run: | diff --git a/Dockerfile b/Dockerfile index a7cd172537..750585a3b6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,45 +1,38 @@ -ARG GO_VERSION="1.23" -ARG ALPINE_VERSION="3.20" +FROM --platform=$BUILDPLATFORM golang:1.23-alpine3.20 AS build -FROM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS build +RUN apk add --no-cache make git WORKDIR /src -RUN go env -w GOMODCACHE=/root/.cache/go-build COPY go.mod go.sum *.go VERSION ./ ARG GO_PROXY="https://proxy.golang.org" ENV GOPROXY=${GO_PROXY} -RUN --mount=type=cache,target=/root/.cache/go-build go mod download +RUN go mod download COPY . . -RUN --mount=type=cache,target=/root/.cache/go-build \ - export VERSION=$(go run api/version/generate/release_generate.go print-rc-version) && \ - export NOW=$(date -u +%FT%T%z) && \ - go build -trimpath -ldflags \ - "-s -w -X ocm.software/ocm/api/version.gitVersion=$VERSION -X ocm.software/ocm/api/version.buildDate=$NOW" \ - -o /bin/ocm ./cmds/ocm/main.go -FROM alpine:${ALPINE_VERSION} +ENV BUILD_FLAGS="-trimpath" -# Create group and user -ARG UID=1000 -ARG GID=1000 -RUN addgroup -g "${GID}" ocmGroup && adduser -u "${UID}" ocmUser -G ocmGroup -D +# the GOARCH has not a default value to allow the binary be built according to the host where the command +# was called. For example, if we call make docker-build in a local env which has the Apple Silicon SO +# the docker BUILDPLATFORM arg will be linux/arm64 when for Apple x86 it will be linux/amd64. Therefore, +# by leaving it empty we can ensure that the container and binary shipped on it will have the same platform. +RUN make bin/ocm GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} -COPY --from=build /bin/ocm /bin/ocm -COPY --chmod=0755 components/ocmcli/ocm.sh /bin/ocm.sh +FROM gcr.io/distroless/static-debian12:nonroot@sha256:6cd937e9155bdfd805d1b94e037f9d6a899603306030936a3b11680af0c2ed58 + +COPY --from=build /src/bin/ocm /usr/local/bin/ocm # https://github.com/opencontainers/image-spec/blob/main/annotations.md#pre-defined-annotation-keys -LABEL org.opencontainers.image.description="Open Component Model command line interface based on Alpine ${ALPINE_VERSION}" +LABEL org.opencontainers.image.description="Open Component Model command line interface based on Distroless" LABEL org.opencontainers.image.vendor="SAP SE" LABEL org.opencontainers.image.licenses="Apache-2.0" LABEL org.opencontainers.image.url="https://ocm.software/" LABEL org.opencontainers.image.source="https://github.com/open-component-model/ocm" LABEL org.opencontainers.image.title="ocm" LABEL org.opencontainers.image.documentation="https://github.com/open-component-model/ocm/blob/main/docs/reference/ocm.md" -LABEL org.opencontainers.image.base.name="alpine:${ALPINE_VERSION}" +LABEL org.opencontainers.image.base.name="gcr.io/distroless/static-debian12:nonroot" -USER ocmUser -ENTRYPOINT ["/bin/ocm.sh"] -CMD ["/bin/ocm"] +ENTRYPOINT ["/usr/local/bin/ocm"] +CMD ["version"] diff --git a/Makefile b/Makefile index 726de3d3f2..87542905e6 100644 --- a/Makefile +++ b/Makefile @@ -26,12 +26,14 @@ SOURCES := $(shell go list -f '{{$$I:=.Dir}}{{range .GoFiles }}{{$$I}}/{{.}} {{e GOPATH := $(shell go env GOPATH) NOW := $(shell date -u +%FT%T%z) -BUILD_FLAGS := "-s -w \ +LD_FLAGS := "-s -w \ -X ocm.software/ocm/api/version.gitVersion=$(EFFECTIVE_VERSION) \ -X ocm.software/ocm/api/version.gitTreeState=$(GIT_TREE_STATE) \ -X ocm.software/ocm/api/version.gitCommit=$(COMMIT) \ -X ocm.software/ocm/api/version.buildDate=$(NOW)" CGO_ENABLED := 0 +GOOS := $(shell go env GOOS) +GOARCH := $(shell go env GOARCH) COMPONENTS ?= ocmcli helminstaller demoplugin ecrplugin helmdemo subchartsdemo @@ -42,19 +44,19 @@ bin: mkdir -p bin bin/ocm: bin $(SOURCES) - CGO_ENABLED=$(CGO_ENABLED) go build -ldflags $(BUILD_FLAGS) -o bin/ocm ./cmds/ocm + CGO_ENABLED=$(CGO_ENABLED) GOOS=$(GOOS) GOARCH=$(GOARCH) go build $(BUILD_FLAGS) -ldflags $(LD_FLAGS) -o bin/ocm ./cmds/ocm bin/helminstaller: bin $(SOURCES) - CGO_ENABLED=$(CGO_ENABLED) go build -ldflags $(BUILD_FLAGS) -o bin/helminstaller ./cmds/helminstaller + CGO_ENABLED=$(CGO_ENABLED) GOOS=$(GOOS) GOARCH=$(GOARCH) go build $(BUILD_FLAGS) -ldflags $(LD_FLAGS) -o bin/helminstaller ./cmds/helminstaller bin/demo: bin $(SOURCES) - CGO_ENABLED=$(CGO_ENABLED) go build -ldflags $(BUILD_FLAGS) -o bin/demo ./cmds/demoplugin + CGO_ENABLED=$(CGO_ENABLED) GOOS=$(GOOS) GOARCH=$(GOARCH) go build $(BUILD_FLAGS) -ldflags $(LD_FLAGS) -o bin/demo ./cmds/demoplugin bin/cliplugin: bin $(SOURCES) - CGO_ENABLED=$(CGO_ENABLED) go build -ldflags $(BUILD_FLAGS) -o bin/cliplugin ./cmds/cliplugin + CGO_ENABLED=$(CGO_ENABLED) GOOS=$(GOOS) GOARCH=$(GOARCH) go build $(BUILD_FLAGS) -ldflags $(LD_FLAGS) -o bin/cliplugin ./cmds/cliplugin bin/ecrplugin: bin $(SOURCES) - CGO_ENABLED=$(CGO_ENABLED) go build -ldflags $(BUILD_FLAGS) -o bin/ecrplugin ./cmds/ecrplugin + CGO_ENABLED=$(CGO_ENABLED) GOOS=$(GOOS) GOARCH=$(GOARCH) go build $(BUILD_FLAGS) -ldflags $(LD_FLAGS) -o bin/ecrplugin ./cmds/ecrplugin api: $(SOURCES) go build ./api/... diff --git a/RELEASE_PROCESS.md b/RELEASE_PROCESS.md index 181dcbbc50..262b6da560 100644 --- a/RELEASE_PROCESS.md +++ b/RELEASE_PROCESS.md @@ -18,8 +18,8 @@ created. The release branches are initially created from the `main` branch via the GitHub action [`Release Branch Creation`](./.github/workflows/release-branch.yaml). -A release is generated by calling a specific [ -`release`](./.github/workflows/release.yaml) GitHub Action. It is +A release is generated by calling a specific +[`release`](./.github/workflows/release.yaml) GitHub Action. It is executed on the branch which should be released - regardless whether it is a patch or a minor release. @@ -63,11 +63,11 @@ gitGraph TB: ### The Release Branch Creation / Cutoff -Every minor release starts with the creation of a release branch through [ -`Release Branch Creation`](./.github/workflows/release-branch.yaml). +Every minor release starts with the creation of a release branch through +[`Release Branch Creation`](./.github/workflows/release-branch.yaml). -The version / minor of the release is based on the content of the file [ -`VERSION`](./VERSION) which +The version / minor of the release is based on the content of the file +[`VERSION`](./VERSION) which is updated automatically said `release` action. During development, the content of this file is the complete release name of the release currently under development and the suffix `-dev` (e.g. `0.1.0-dev`). The content of this file @@ -93,8 +93,8 @@ This means that: the release manager - Any bug fix that is not deemed critical must be approved by the release manager -- Any bug fix must first be merged to main and then [ - `cherry-picked`](https://git-scm.com/docs/git-cherry-pick) to the release +- Any bug fix must first be merged to main and then + [`cherry-picked`](https://git-scm.com/docs/git-cherry-pick) to the release branch. At this point in time, any release targeted on this branch will have this minor @@ -143,12 +143,12 @@ and after a grace period, promote the draft release to a full release. This promotion is currently effectively a full rebuild from the release branch, with the difference that the `-rc.` suffix is removed. -After the build, instead of finishing, the [ -`release`](./.github/workflows/release.yaml) GitHub Action will also publish the +After the build, instead of finishing, the +[`release`](./.github/workflows/release.yaml) GitHub Action will also publish the release. -This publishing to package registries (such as brew) is delegated to [ -`publish-to-other-than-github`](./.github/workflows/publish-to-other-than-github.yaml) +This publishing to package registries (such as brew) is delegated to +[`publish-to-other-than-github`](./.github/workflows/publish-to-other-than-github.yaml) After the official release on a release branch was successful, the version is considered `burned`. This means that, even if bugs are found for that release in the future, a @@ -244,3 +244,29 @@ branches were created on demand. This model has now largely been replaced by the model we see in this document. However you might still encounter leftovers form the old model and you are encouraged to create issues regarding inconsistencies. + +## Follow up actions + +Review and merge open pull requests at the following locations. +See [Publish Release to other package registries than Github](https://github.com/open-component-model/ocm/actions/workflows/publish-to-other-than-github.yaml) workflow runs. +In case of error you can try to [Manually retrigger the publishing of ocm-cli to other repositories](https://github.com/open-component-model/ocm/actions/workflows/retrigger-publish-to-other.yaml). + +### ocm-website + +[Update the website](https://github.com/open-component-model/ocm-website/pulls). + +### homebrew-tap + +[Update brew tap](https://github.com/open-component-model/homebrew-tap/pulls). + +### winget-pkgs + +[Check winget-pkgs PRs for: `New version: Open-Component-Model.ocm-cli`](https://github.com/microsoft/winget-pkgs/pulls?q=is%3Apr+is%3Aopen+New+version%3A+Open-Component-Model.ocm-cli). + +### chocolatey + +[Check the `Packages in Moderation`](https://community.chocolatey.org/profiles/ocm.software#profile-moderation). + +### piper-ocm-cli + +[Update piper-ocm-cli](https://github.tools.sap/open-component-model/piper-ocm-cli/pulls). diff --git a/VERSION b/VERSION index 7120f981c5..821e168310 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.19.0-dev +0.20.0-dev diff --git a/api/utils/template/merge.go b/api/utils/template/merge.go index 7c8da61625..b349e40458 100644 --- a/api/utils/template/merge.go +++ b/api/utils/template/merge.go @@ -3,7 +3,7 @@ package template import ( "encoding/json" - "github.com/imdario/mergo" + "dario.cat/mergo" "sigs.k8s.io/yaml" ) diff --git a/components/helminstaller/Makefile b/components/helminstaller/Makefile index e6c8d43b1c..9dafc4da79 100644 --- a/components/helminstaller/Makefile +++ b/components/helminstaller/Makefile @@ -23,6 +23,14 @@ PLATFORM := $(shell go env GOOS)/$(shell g CACHE_DIR := $(shell go env GOCACHE) MOD_CACHE_DIR := $(shell go env GOMODCACHE) + +ifneq ($(BUILDX_CACHE_REF),) + ADDITIONAL_BUILDX_ARGS += --cache-from type=registry,ref=$(BUILDX_CACHE_REF) + ifeq ($(BUILDX_CACHE_PUSH),true) + ADDITIONAL_BUILDX_ARGS += --cache-to type=registry,ref=$(BUILDX_CACHE_REF) + endif +endif + CREDS ?= # Define the path to the binary OCM_BIN = $(REPO_ROOT)/bin/ocm @@ -48,7 +56,7 @@ BUILD_FLAGS := "-s -w \ -X ocm.software/ocm/api/version.buildDate=$(NOW)" CMDSRCS=$(shell find $(REPO_ROOT)/cmds/$(NAME) -type f) -OCMSRCS=$(shell find $(REPO_ROOT)/pkg -type f) $(REPO_ROOT)/go.* +OCMSRCS=$(shell find $(REPO_ROOT)/api -type f) $(REPO_ROOT)/go.* ifeq ($(MULTI),true) FLAGSUF = .multi @@ -89,7 +97,7 @@ $(GEN)/image.$(NAME): $(GEN)/.exists Dockerfile $(CMDSRCS) $(OCMSRCS) --build-arg CACHE_DIR=$(CACHE_DIR) \ --build-arg MOD_CACHE_DIR=$(MOD_CACHE_DIR) \ --build-arg EFFECTIVE_VERSION=$(EFFECTIVE_VERSION) \ - --build-arg GIT_TREE_STATE=$(GIT_TREE_STATE); \ + --build-arg GIT_TREE_STATE=$(GIT_TREE_STATE) $(ADDITIONAL_BUILDX_ARGS); \ @touch $(GEN)/image.$(NAME) push-image: @@ -108,7 +116,7 @@ $(GEN)/image.$(NAME).multi: $(GEN)/.exists Dockerfile $(CMDSRCS) $(OCMSRCS) --build-arg CACHE_DIR=$(CACHE_DIR) \ --build-arg MOD_CACHE_DIR=$(MOD_CACHE_DIR) \ --build-arg EFFECTIVE_VERSION=$(EFFECTIVE_VERSION) \ - --build-arg GIT_TREE_STATE=$(GIT_TREE_STATE); \ + --build-arg GIT_TREE_STATE=$(GIT_TREE_STATE) $(ADDITIONAL_BUILDX_ARGS); \ done @touch $(GEN)/image.$(NAME).multi diff --git a/components/ocmcli/Dockerfile b/components/ocmcli/Dockerfile deleted file mode 100644 index dc5a504d7e..0000000000 --- a/components/ocmcli/Dockerfile +++ /dev/null @@ -1,31 +0,0 @@ -# This Dockerfile is used by `make` via the Makefile - -ARG ALPINE_VERSION="3.20.2" -FROM --platform=$BUILDPLATFORM alpine:${ALPINE_VERSION} - -# Create group and user -ARG UID=1000 -ARG GID=1000 -RUN addgroup -g "${GID}" ocmGroup && adduser -u "${UID}" ocmUser -G ocmGroup -D - -ARG SUFFIX -ARG OCM_VERSION - -COPY gen/ocmcli/ocmcli.$SUFFIX /bin/ocm -COPY --chmod=0755 components/ocmcli/ocm.sh /bin/ocm.sh - -# https://github.com/opencontainers/image-spec/blob/main/annotations.md#pre-defined-annotation-keys -LABEL org.opencontainers.image.description="Open Component Model command line interface based on Alpine ${ALPINE_VERSION}" -LABEL org.opencontainers.image.vendor="SAP SE" -LABEL org.opencontainers.image.licenses="Apache-2.0" -LABEL org.opencontainers.image.url="https://ocm.software/" -LABEL org.opencontainers.image.source="https://github.com/open-component-model/ocm" -LABEL org.opencontainers.image.title="ocm" -LABEL org.opencontainers.image.version="${OCM_VERSION}" -LABEL org.opencontainers.image.revision="${OCM_VERSION}" -LABEL org.opencontainers.image.documentation="https://github.com/open-component-model/ocm/blob/main/docs/reference/ocm.md" -LABEL org.opencontainers.image.base.name="alpine:${ALPINE_VERSION}" - -USER ocmUser -ENTRYPOINT ["/bin/ocm.sh"] -CMD ["/bin/ocm"] diff --git a/components/ocmcli/Makefile b/components/ocmcli/Makefile index 18d955580f..aa5174f443 100644 --- a/components/ocmcli/Makefile +++ b/components/ocmcli/Makefile @@ -31,6 +31,13 @@ ifeq ($(MULTI),true) FLAGSUF = .multi endif +ifneq ($(BUILDX_CACHE_REF),) + ADDITIONAL_BUILDX_ARGS += --cache-from type=registry,ref=$(BUILDX_CACHE_REF) + ifeq ($(BUILDX_CACHE_PUSH),true) + ADDITIONAL_BUILDX_ARGS += --cache-to type=registry,ref=$(BUILDX_CACHE_REF),mode=max + endif +endif + CREDS ?= # Define the path to the binary OCM_BIN = $(REPO_ROOT)/bin/ocm @@ -55,8 +62,6 @@ BUILD_FLAGS := "-s -w \ -X ocm.software/ocm/api/version.gitCommit=$(COMMIT) \ -X ocm.software/ocm/api/version.buildDate=$(NOW)" -ALPINE_LATEST_VER=$(shell curl -s https://registry.hub.docker.com/v2/repositories/library/alpine/tags | jq '.results[1].name' | xargs) - .PHONY: build build: $(GEN)/build @@ -70,44 +75,35 @@ $(GEN)/build: $(GEN) $(GEN)/.exists $(CMDSRCS) $(OCMSRCS) @touch $(GEN)/build .PHONY: image -image: $(GEN)/image - -$(GEN)/image: $(GEN)/.exists Dockerfile $(GEN)/build +image: @PLATFORM_OS_OVERRIDE=$(PLATFORM_OS); \ if [ $$PLATFORM_OS_OVERRIDE == darwin ]; then \ echo; echo "Building linux instead of darwin as there's no native Docker platform for darwin"; echo; \ - docker buildx build -t $(IMAGE):$(VERSION) --platform linux/$(PLATFORM_ARCH) --file Dockerfile $(REPO_ROOT) \ - --build-arg OCM_VERSION=$(EFFECTIVE_VERSION) \ - --build-arg ALPINE_VERSION=$(ALPINE_LATEST_VER) \ - --build-arg SUFFIX=$$(echo linux/$(PLATFORM_ARCH) | sed -e s:/:-:g); \ + docker buildx build -t $(IMAGE):$(VERSION) --platform linux/$(PLATFORM_ARCH) --file $(REPO_ROOT)/Dockerfile $(REPO_ROOT) \ + --label org.opencontainers.image.version=$(VERSION) \ + --label org.opencontainers.image.revision=$(VERSION) $(ADDITIONAL_BUILDX_ARGS); \ else \ echo; echo "Building for $(PLATFORM_OS)/$(ARCH)"; echo; \ - docker buildx build -t $(IMAGE):$(VERSION) --platform $(PLATFORM_OS)/$(PLATFORM_ARCH) --file Dockerfile $(REPO_ROOT) \ - --build-arg OCM_VERSION=$(EFFECTIVE_VERSION) \ - --build-arg ALPINE_VERSION=$(ALPINE_LATEST_VER) \ - --build-arg SUFFIX=$$(echo $(PLATFORM_OS)/$(PLATFORM_ARCH) | sed -e s:/:-:g); \ + docker buildx build -t $(IMAGE):$(VERSION) --platform $(PLATFORM_OS)/$(PLATFORM_ARCH) --file $(REPO_ROOT)/Dockerfile $(REPO_ROOT) \ + --label org.opencontainers.image.version=$(VERSION) \ + --label org.opencontainers.image.revision=$(VERSION) $(ADDITIONAL_BUILDX_ARGS); \ fi - @touch $(GEN)/image .PHONY: image.multi -image.multi: $(GEN)/image.multi - -$(GEN)/image.multi: Dockerfile $(GEN)/build - echo "Building with Alpine version: ${ALPINE_LATEST_VER}" +image.multi: for i in $(IMAGE_PLATFORMS); do \ - tag=$$(echo $$i | sed -e s:/:-:g); \ - echo building platform $$i; \ - docker buildx build --load -t $(IMAGE):$(VERSION)-$$tag --platform $$i --file Dockerfile $(REPO_ROOT) \ - --build-arg OCM_VERSION=$(EFFECTIVE_VERSION) \ - --build-arg ALPINE_VERSION=$(ALPINE_LATEST_VER) \ - --build-arg SUFFIX=$$tag; \ + tag=$$(echo $$i | sed -e s:/:-:g); \ + echo building platform $$i; \ + docker buildx build --load -t $(IMAGE):$(VERSION)-$$tag --platform $$i --file $(REPO_ROOT)/Dockerfile $(REPO_ROOT) \ + --build-arg OCM_VERSION=$(EFFECTIVE_VERSION) \ + --label org.opencontainers.image.version=$(VERSION) \ + --label org.opencontainers.image.revision=$(VERSION) $(ADDITIONAL_BUILDX_ARGS); \ done - @touch $(GEN)/image.multi .PHONY: ctf ctf: $(GEN)/ctf -$(GEN)/ctf: $(OCM_BIN) $(GEN)/.exists $(GEN)/build $(GEN)/image$(FLAGSUF) component-constructor.yaml $(CHARTSRCS) Makefile +$(GEN)/ctf: $(OCM_BIN) $(GEN)/.exists $(GEN)/build image$(FLAGSUF) component-constructor.yaml $(CHARTSRCS) Makefile @rm -rf "$(GEN)/ctf" $(OCM) add componentversions \ --create \ diff --git a/components/ocmcli/ocm.sh b/components/ocmcli/ocm.sh deleted file mode 100644 index 0225d4c62d..0000000000 --- a/components/ocmcli/ocm.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/sh -set -e - -# this if will check if the first argument is a flag but only works if all arguments require a hyphenated flag -v; -SL; -f arg; etc will work, but not arg1 arg2 -if [ "$#" -eq 0 ] || [ "${1#-}" != "$1" ]; then - set -- "$@" - exec /bin/ocm "$@" - return -fi - -# this case will check if the first argument is a known OCM command -case $1 in - add | bootstrap | cache | check | clean | completion | controller | create | credentials | describe | download | execute | get | hash | help | install | oci | ocm | show | sign | toi | transfer | verify | version) - exec /bin/ocm "$@" - return - ;; -esac - -# else default to run whatever the user wanted like "bash" or "sh" -exec "$@" diff --git a/flake.nix b/flake.nix index 701c062f33..77c0e3bf98 100644 --- a/flake.nix +++ b/flake.nix @@ -35,7 +35,7 @@ state = if (self ? rev) then "clean" else "dirty"; # This vendorHash represents a derivative of all go.mod dependencies and needs to be adjusted with every change - vendorHash = "sha256-o3425Wh5uarsBFQZxciE0jDfSapzu+AjeKf4/FM5kW8="; + vendorHash = "sha256-dWwvxRCeY9eNqUYijpGWRE76ZQYbBgpgH96LzSn8jJ8="; src = ./.; diff --git a/go.mod b/go.mod index 4623b27dde..ce8145cef0 100644 --- a/go.mod +++ b/go.mod @@ -5,15 +5,16 @@ go 1.23.2 replace github.com/spf13/cobra => github.com/open-component-model/cobra v0.0.0-20230329075350-b1fd876abfb9 require ( + dario.cat/mergo v1.0.1 github.com/DataDog/gostackparse v0.7.0 github.com/InfiniteLoopSpace/go_S-MIME v0.0.0-20181221134359-3f58f9a4b2b6 github.com/Masterminds/semver/v3 v3.3.1 github.com/aws/aws-sdk-go-v2 v1.32.5 github.com/aws/aws-sdk-go-v2/config v1.28.5 github.com/aws/aws-sdk-go-v2/credentials v1.17.46 - github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.17.40 + github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.17.41 github.com/aws/aws-sdk-go-v2/service/ecr v1.36.6 - github.com/aws/aws-sdk-go-v2/service/s3 v1.68.0 + github.com/aws/aws-sdk-go-v2/service/s3 v1.69.0 github.com/cloudflare/cfssl v1.6.5 github.com/containerd/containerd v1.7.24 github.com/containerd/errdefs v1.0.0 @@ -37,7 +38,6 @@ require ( github.com/golang/mock v1.6.0 github.com/google/go-github/v45 v45.2.0 github.com/hashicorp/vault-client-go v0.4.3 - github.com/imdario/mergo v0.3.16 github.com/juju/fslock v0.0.0-20160525022230-4d5c94c67b4b github.com/klauspost/compress v1.17.11 github.com/klauspost/pgzip v1.2.6 @@ -52,7 +52,7 @@ require ( github.com/mittwald/go-helm-client v0.12.14 github.com/modern-go/reflect2 v1.0.2 github.com/onsi/ginkgo/v2 v2.22.0 - github.com/onsi/gomega v1.35.1 + github.com/onsi/gomega v1.36.0 github.com/opencontainers/go-digest v1.0.0 github.com/opencontainers/image-spec v1.1.0 github.com/pkg/errors v0.9.1 @@ -89,7 +89,6 @@ require ( cloud.google.com/go/auth v0.10.2 // indirect cloud.google.com/go/auth/oauth2adapt v0.2.5 // indirect cloud.google.com/go/compute/metadata v0.5.2 // indirect - dario.cat/mergo v1.0.1 // indirect filippo.io/edwards25519 v1.1.0 // indirect github.com/AdaLogics/go-fuzz-headers v0.0.0-20240806141605-e8a1dd7889d6 // indirect github.com/AliyunContainerService/ack-ram-tool/pkg/credentials/provider v0.15.2 // indirect @@ -234,6 +233,7 @@ require ( github.com/hashicorp/go-secure-stdlib/strutil v0.1.2 // indirect github.com/hashicorp/hcl v1.0.1-vault-5 // indirect github.com/huandu/xstrings v1.5.0 // indirect + github.com/imdario/mergo v0.3.16 // indirect github.com/in-toto/in-toto-golang v0.9.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/jedisct1/go-minisign v0.0.0-20230811132847-661be99b8267 // indirect @@ -368,6 +368,9 @@ require ( sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect ) +// see https://github.com/darccio/mergo?tab=readme-ov-file#100 +replace github.com/imdario/mergo => github.com/imdario/mergo v0.3.16 + retract [v0.16.0, v0.16.9] // Retract all from v0.16 due to https://github.com/open-component-model/ocm-project/issues/293 // crypto/tls: Client Hello is always sent in 2 TCP frames if GODEBUG=tlskyber=1 (default) which causes diff --git a/go.sum b/go.sum index e7febab052..e6fda21192 100644 --- a/go.sum +++ b/go.sum @@ -175,8 +175,8 @@ github.com/aws/aws-sdk-go-v2/credentials v1.17.46 h1:AU7RcriIo2lXjUfHFnFKYsLCwgb github.com/aws/aws-sdk-go-v2/credentials v1.17.46/go.mod h1:1FmYyLGL08KQXQ6mcTlifyFXfJVCNJTVGuQP4m0d/UA= github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.20 h1:sDSXIrlsFSFJtWKLQS4PUWRvrT580rrnuLydJrCQ/yA= github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.20/go.mod h1:WZ/c+w0ofps+/OUqMwWgnfrgzZH1DZO1RIkktICsqnY= -github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.17.40 h1:CbalQNEYQljzAJ+3beY8FQBShdLNLpJzHL4h/5LSFMc= -github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.17.40/go.mod h1:1iYVr/urNWuZ7WZ1829FSE7RRTaXvzFdwrEQV8Z40cE= +github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.17.41 h1:hqcxMc2g/MwwnRMod9n6Bd+t+9Nf7d5qRg7RaXKPd6o= +github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.17.41/go.mod h1:d1eH0VrttvPmrCraU68LOyNdu26zFxQFjrVSb5vdhog= github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.24 h1:4usbeaes3yJnCFC7kfeyhkdkPtoRYPa/hTmCqMpKpLI= github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.24/go.mod h1:5CI1JemjVwde8m2WG3cz23qHKPOxbpkq0HaoreEgLIY= github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.24 h1:N1zsICrQglfzaBnrfM0Ys00860C+QFwu6u/5+LomP+o= @@ -199,8 +199,8 @@ github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.5 h1:P1doBzv5VEg1ON github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.5/go.mod h1:NOP+euMW7W3Ukt28tAxPuoWao4rhhqJD3QEBk7oCg7w= github.com/aws/aws-sdk-go-v2/service/kms v1.37.5 h1:5dQJ6Q5QrQOqZxXjSbRXukBqU8Pgu6Ro6Qqtyd8yiz4= github.com/aws/aws-sdk-go-v2/service/kms v1.37.5/go.mod h1:A9vfQcNHVBCE7ZZN6H+UUJpXtbH26Vv6L7Zhk5nIJAY= -github.com/aws/aws-sdk-go-v2/service/s3 v1.68.0 h1:bFpcqdwtAEsgpZXvkTxIThFQx/EM0oV6kXmfFIGjxME= -github.com/aws/aws-sdk-go-v2/service/s3 v1.68.0/go.mod h1:ralv4XawHjEMaHOWnTFushl0WRqim/gQWesAMF6hTow= +github.com/aws/aws-sdk-go-v2/service/s3 v1.69.0 h1:Q2ax8S21clKOnHhhr933xm3JxdJebql+R7aNo7p7GBQ= +github.com/aws/aws-sdk-go-v2/service/s3 v1.69.0/go.mod h1:ralv4XawHjEMaHOWnTFushl0WRqim/gQWesAMF6hTow= github.com/aws/aws-sdk-go-v2/service/sso v1.24.6 h1:3zu537oLmsPfDMyjnUS2g+F2vITgy5pB74tHI+JBNoM= github.com/aws/aws-sdk-go-v2/service/sso v1.24.6/go.mod h1:WJSZH2ZvepM6t6jwu4w/Z45Eoi75lPN7DcydSRtJg6Y= github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.5 h1:K0OQAsDywb0ltlFrZm0JHPY3yZp/S9OaoLU33S7vPS8= @@ -803,8 +803,8 @@ github.com/onsi/gomega v1.9.0/go.mod h1:Ho0h+IUsWyvy1OpqCwxlQ/21gkhVunqlU8fDGcoT github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY= github.com/onsi/gomega v1.19.0/go.mod h1:LY+I3pBVzYsTBU1AnDwOSxaYi9WoWiqgwooUqq9yPro= -github.com/onsi/gomega v1.35.1 h1:Cwbd75ZBPxFSuZ6T+rN/WCb/gOc6YgFBXLlZLhC7Ds4= -github.com/onsi/gomega v1.35.1/go.mod h1:PvZbdDc8J6XJEpDK4HCuRBm8a6Fzp9/DmhC9C7yFlog= +github.com/onsi/gomega v1.36.0 h1:Pb12RlruUtj4XUuPUqeEWc6j5DkVVVA49Uf6YLfC95Y= +github.com/onsi/gomega v1.36.0/go.mod h1:PvZbdDc8J6XJEpDK4HCuRBm8a6Fzp9/DmhC9C7yFlog= github.com/open-component-model/cobra v0.0.0-20230329075350-b1fd876abfb9 h1:b2cJvZ8nWAVvCqvPhUaFl26Wht4nM4mqfl2ksY9lVzU= github.com/open-component-model/cobra v0.0.0-20230329075350-b1fd876abfb9/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0= github.com/open-policy-agent/opa v0.68.0 h1:Jl3U2vXRjwk7JrHmS19U3HZO5qxQRinQbJ2eCJYSqJQ= diff --git a/hack/collapse/.gitignore b/hack/collapse/.gitignore new file mode 100644 index 0000000000..edf5bf79b3 --- /dev/null +++ b/hack/collapse/.gitignore @@ -0,0 +1 @@ +test_example_collapsible.md \ No newline at end of file diff --git a/hack/collapse/auto_collapse.sh b/hack/collapse/auto_collapse.sh new file mode 100755 index 0000000000..31d7803238 --- /dev/null +++ b/hack/collapse/auto_collapse.sh @@ -0,0 +1,115 @@ +#!/bin/bash + +# allow > to overwrite files +set +o noclobber + +# Auto Collapse +#This is a script that takes in +# - a markdown file +# - a designated output file +# - the number of lines as a threshold on when to collapse a section. +# +# Sample +# ./auto_collapse.sh test_example.md test_example_collapsible.md 5 + +# Input and output files +INPUT_FILE=${1:-"README.md"} +OUTPUT_FILE=${2:-"README_collapsible.md"} +THRESHOLD=${3:-10} + +# Ensure output file is empty initially +true > "$OUTPUT_FILE" + +# Variables to track sections +inside_section=false +section_lines=() +section_header="" +last_line="" + +# Function to count changes (lines starting with '*') +count_changes() { + local lines=("$@") + local count=0 + for line in "${lines[@]}"; do + if [[ $line =~ ^\* ]]; then + ((count++)) + fi + done + echo "$count" +} + +# Function to process and write a section +write_section() { + local header="$1" + local lines=("${@:2}") + local num_changes + num_changes=$(count_changes "${lines[@]}") + + # Write the section header as is + echo "$header" >> "$OUTPUT_FILE" + + if [[ $num_changes -gt $THRESHOLD ]]; then + # Collapse only the content with a dynamic summary + { + echo "
" + echo "${num_changes} changes" + echo "" + printf "%s\n" "${lines[@]}" + echo "
" + echo "" + } >> "$OUTPUT_FILE" + else + # Write the content as is if it's below the threshold + printf "%s\n" "${lines[@]}" >> "$OUTPUT_FILE" + fi +} + +# Read the Markdown file line by line +while IFS= read -r line || [[ -n $line ]]; do + # Check if the line contains "Full Changelog" + if [[ $line =~ ^\*\*Full\ Changelog ]]; then + # Finalize any pending section + if [[ $inside_section == true ]]; then + write_section "$section_header" "${section_lines[@]:1}" # Exclude the header + inside_section=false + fi + last_line="$line" + continue + fi + + # Preserve comment blocks + if [[ $line =~ ^\ + +## What's Changed +### 🚀 Features +* feat(log): log http requests for OCI and docker based on trace level by injecting a logger by @author in https://github.com/open-component-model/ocm/pull/1118 +### 🧰 Maintenance +* chore: change guide for 0.18.0 by @author in https://github.com/open-component-model/ocm/pull/1066 +* chore: allow publishing to Brew via custom script by @author in https://github.com/open-component-model/ocm/pull/1059 +* chore: remove ocm inception during build CTF aggregation by @author in https://github.com/open-component-model/ocm/pull/1065 +* chore: release branches as `releases/vX.Y` instead of `releases/vX.Y.Z` by @author in https://github.com/open-component-model/ocm/pull/1071 +* chore: cleanup release action by @author in https://github.com/open-component-model/ocm/pull/1076 +* chore: bump version to 0.19.0-dev by @author in https://github.com/open-component-model/ocm/pull/1084 +* chore: disable mandatory period comments by @author in https://github.com/open-component-model/ocm/pull/1079 +### Some other +* chore: change guide for 0.18.0 by @author in +* chore: allow publishing to Brew via custom script by @author in + +**Full Changelog**: https://github.com/open-component-model/ocm/compare/v0.18...v0.19.0 + \ No newline at end of file diff --git a/hack/collapse/test_example_expected_collapsible.md b/hack/collapse/test_example_expected_collapsible.md new file mode 100644 index 0000000000..9ab77e97e9 --- /dev/null +++ b/hack/collapse/test_example_expected_collapsible.md @@ -0,0 +1,26 @@ + + +## What's Changed + +### 🚀 Features +* feat(log): log http requests for OCI and docker based on trace level by injecting a logger by @author in https://github.com/open-component-model/ocm/pull/1118 +### 🧰 Maintenance +
+7 changes + +* chore: change guide for 0.18.0 by @author in https://github.com/open-component-model/ocm/pull/1066 +* chore: allow publishing to Brew via custom script by @author in https://github.com/open-component-model/ocm/pull/1059 +* chore: remove ocm inception during build CTF aggregation by @author in https://github.com/open-component-model/ocm/pull/1065 +* chore: release branches as `releases/vX.Y` instead of `releases/vX.Y.Z` by @author in https://github.com/open-component-model/ocm/pull/1071 +* chore: cleanup release action by @author in https://github.com/open-component-model/ocm/pull/1076 +* chore: bump version to 0.19.0-dev by @author in https://github.com/open-component-model/ocm/pull/1084 +* chore: disable mandatory period comments by @author in https://github.com/open-component-model/ocm/pull/1079 +
+ +### Some other +* chore: change guide for 0.18.0 by @author in +* chore: allow publishing to Brew via custom script by @author in + + + +**Full Changelog**: https://github.com/open-component-model/ocm/compare/v0.18...v0.19.0 \ No newline at end of file