From 25b71b512c2e41ade90ae1af6d84f5648b54d6bf Mon Sep 17 00:00:00 2001 From: Maximilian Techritz Date: Wed, 18 Jun 2025 14:56:40 +0200 Subject: [PATCH] ci: update workflows --- .github/workflows/ci.yaml | 18 +++++ .github/workflows/license-check.yaml | 37 --------- .github/workflows/publish.yaml | 100 ++---------------------- .github/workflows/release.yaml | 113 +-------------------------- .github/workflows/reuse-scan.yaml | 19 ----- .github/workflows/reuse.yaml | 11 +++ .github/workflows/reviewable.yaml | 53 ------------- 7 files changed, 36 insertions(+), 315 deletions(-) create mode 100644 .github/workflows/ci.yaml delete mode 100644 .github/workflows/license-check.yaml delete mode 100644 .github/workflows/reuse-scan.yaml create mode 100644 .github/workflows/reuse.yaml delete mode 100644 .github/workflows/reviewable.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..cb8b3d6 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,18 @@ +name: CI + +on: + push: + tags: + - v* + branches: + - master + - main + pull_request: + +permissions: + contents: read + +jobs: + build_validate_test: + uses: openmcp-project/build/.github/workflows/ci.lib.yaml@main + secrets: inherit diff --git a/.github/workflows/license-check.yaml b/.github/workflows/license-check.yaml deleted file mode 100644 index 5ac0da7..0000000 --- a/.github/workflows/license-check.yaml +++ /dev/null @@ -1,37 +0,0 @@ -name: Check Go Dependency Licenses - -on: - pull_request: - workflow_call: {} - push: - tags: - - v* - branches: - - main - paths: - - go.mod - - go.sum - -permissions: - contents: read - -jobs: - validate: - runs-on: ubuntu-latest - steps: - - name: checkout repo - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - - - uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0 - with: - go-version: '1.24' - - - name: Install go-licenses - run: | - go install github.com/google/go-licenses@latest - - - name: check licenses - # Remove ignore before go live - run: | - go-licenses check --allowed_licenses="Apache-2.0,BSD-3-Clause,MIT,MPL-2.0,ISC,BSD-2-Clause" --ignore github.com/dynatrace-ace/dynatrace-go-api-client ./... - diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 24e25f9..83059c9 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -1,105 +1,15 @@ -name: publish +name: Publish + on: push: tags: - v* workflow_dispatch: - permissions: packages: write -env: - OCI_URL: ghcr.io/openmcp-project - jobs: - release_tag: - name: Release version - runs-on: ubuntu-24.04 - steps: - - name: Checkout code - uses: actions/checkout@v4 - with: - ssh-key: ${{ secrets.PUSH_KEY }} - fetch-tags: true - fetch-depth: 0 - - - name: Read and validate VERSION - id: version - run: | - VERSION=$(cat VERSION) - if [[ ! "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-dev)?$ ]]; then - echo "Invalid version format in VERSION file: $VERSION" - exit 1 - fi - echo "New version: $VERSION" - echo "version=$VERSION" >> $GITHUB_ENV - - - name: Skip release if version is a dev version - if: contains(env.version, '-dev') - run: | - echo "Skipping development version release: ${{ env.version }}" - echo "SKIP=true" >> $GITHUB_ENV - exit 0 - - - name: Set up Docker - uses: docker/setup-docker-action@v4 - with: - daemon-config: | - { - "features": { - "containerd-snapshotter": true - } - } - - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - - name: Set up Docker Context for Buildx - id: buildx-context - run: | - docker context create builders - - - name: Login to GitHub Container Registry - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Set up Docker Buildx - timeout-minutes: 5 - uses: docker/setup-buildx-action@v2 - with: - version: latest - - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version-file: go.mod - - - name: Build the ${{ github.repository }} - run: | - make reviewable - make build-docker-binary - - - name: Build and push Images - run: | - IMG=ghcr.io/openmcp-project/metrics-operator:${{ env.version }} make docker-buildx docker-push - - - name: Package and push helm chart - run: | - make helm-package helm-push - - - name: setup OCM - uses: open-component-model/ocm-setup-action@main - - - name: Create OCM CTF - run: | - ocm add componentversions --create \ - --file ctf component-constructor.yaml \ - --settings settings.yaml -- VERSION=${{ env.version }} - - - name: Push CTF - run: | - ocm transfer ctf --overwrite ./ctf ${{ env.OCI_URL }} + release_publish: + uses: openmcp-project/build/.github/workflows/publish.lib.yaml@main + secrets: inherit \ No newline at end of file diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index a102805..bbdc43f 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -11,114 +11,5 @@ permissions: jobs: release_tag: - name: Release version - runs-on: ubuntu-24.04 - steps: - - name: Checkout code - uses: actions/checkout@v4 - with: - ssh-key: ${{ secrets.PUSH_KEY }} - fetch-tags: true - fetch-depth: 0 - - - name: Read and validate VERSION - id: version - run: | - VERSION=$(cat VERSION) - if [[ ! "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-dev)?$ ]]; then - echo "Invalid version format in VERSION file: $VERSION" - exit 1 - fi - echo "New version: $VERSION" - echo "version=$VERSION" >> $GITHUB_ENV - - - name: Skip release if version is a dev version - if: contains(env.version, '-dev') - run: | - echo "Skipping development version release: ${{ env.version }}" - echo "SKIP=true" >> $GITHUB_ENV - exit 0 - - - name: Check if VERSION is already tagged - id: check_tag - run: | - if git rev-parse "refs/tags/${{ env.version }}" >/dev/null 2>&1; then - echo "Tag ${{ env.version }} already exists. Skipping release." - echo "SKIP=true" >> $GITHUB_ENV - exit 0 - fi - echo "Tag ${{ env.version }} doesn't exists. Proceeding with release." - - - name: Create Git tag - if: ${{ env.SKIP != 'true' }} - run: | - AUTHOR_NAME=$(git log -1 --pretty=format:'%an') - AUTHOR_EMAIL=$(git log -1 --pretty=format:'%ae') - echo "Tagging as $AUTHOR_NAME <$AUTHOR_EMAIL>" - - echo "AUTHOR_NAME=$AUTHOR_NAME" >> $GITHUB_ENV - echo "AUTHOR_EMAIL=$AUTHOR_EMAIL" >> $GITHUB_ENV - - git config user.name "$AUTHOR_NAME" - git config user.email "$AUTHOR_EMAIL" - - git tag -a "${{ env.version }}" -m "Release ${{ env.version }}" - git push origin "${{ env.version }}" - - - name: Build Changelog - id: github_release - - uses: mikepenz/release-changelog-builder-action@v5 - with: - mode: "PR" - configurationJson: | - { - "template": "#{{CHANGELOG}}", - "pr_template": "- #{{TITLE}}: ##{{NUMBER}}", - "categories": [ - { - "title": "## Feature", - "labels": ["feat", "feature"] - }, - { - "title": "## Fix", - "labels": ["fix", "bug"] - }, - { - "title": "## Other", - "labels": [] - } - ], - "label_extractor": [ - { - "pattern": "^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test){1}(\\([\\w\\-\\.]+\\))?(!)?: ([\\w ])+([\\s\\S]*)", - "on_property": "title", - "target": "$1" - } - ] - } - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Create GitHub release - if: ${{ env.SKIP != 'true' }} - uses: softprops/action-gh-release@v2 - with: - tag_name: ${{ env.version }} - name: Release ${{ env.version }} - body: ${{steps.github_release.outputs.changelog}} - draft: true - prerelease: false - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Push dev VERSION - if: ${{ env.SKIP != 'true' }} - run: | - echo "${{ env.version }}-dev" > VERSION - make helm-chart - git config user.name "${{ env.AUTHOR_NAME }}" - git config user.email "${{ env.AUTHOR_EMAIL }}" - git add VERSION charts/metrics-operator/Chart.yaml charts/metrics-operator/values.yaml - git commit -m "chore: update VERSION to ${{ env.version }}-dev" - git push origin main + uses: openmcp-project/build/.github/workflows/release.lib.yaml@main + secrets: inherit diff --git a/.github/workflows/reuse-scan.yaml b/.github/workflows/reuse-scan.yaml deleted file mode 100644 index 195930d..0000000 --- a/.github/workflows/reuse-scan.yaml +++ /dev/null @@ -1,19 +0,0 @@ -# This workflow is triggered by the user and runs the REUSE compliance check (reuse lint) on the repository. - -name: REUSE Compliance Check - -on: - pull_request: - workflow_call: {} - push: - branches: - - main - - -jobs: - lint-reuse: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - - name: REUSE Compliance Check - uses: fsfe/reuse-action@3ae3c6bdf1257ab19397fab11fd3312144692083 # v4.0.0 diff --git a/.github/workflows/reuse.yaml b/.github/workflows/reuse.yaml new file mode 100644 index 0000000..aa0ba49 --- /dev/null +++ b/.github/workflows/reuse.yaml @@ -0,0 +1,11 @@ +name: REUSE Compliance Check + +on: [push, pull_request] + +permissions: + contents: read + +jobs: + run_reuse: + uses: openmcp-project/build/.github/workflows/reuse.lib.yaml@main + secrets: inherit diff --git a/.github/workflows/reviewable.yaml b/.github/workflows/reviewable.yaml deleted file mode 100644 index c1c4587..0000000 --- a/.github/workflows/reviewable.yaml +++ /dev/null @@ -1,53 +0,0 @@ -# This workflow will run make reviewable and make check-diff as checks - -name: make reviewable && make check-Diff - -on: - pull_request: - workflow_call: {} - push: - tags: - - v* - branches: - - main - -env: - GO_IMPORT_VERSION: 'v0.16.1' - -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - submodules: true - - - name: Set up Go - uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0 - with: - go-version: '1.24' - - - name: Install goimports - run: | - cd /tmp - go install golang.org/x/tools/cmd/goimports@${{ env.GO_IMPORT_VERSION }} - - - name: make reviewable - run: make reviewable - env: - RUNNING_IN_CI: 'true' - - - name: tidy - run: go mod tidy - - - name: sync chart version - run: make helm-chart - - - name: make check-diff - run: make check-diff - - - name: run tests - run: make test - - - name: build - run: make build