diff --git a/.dagger/go.mod b/.dagger/go.mod index b5044a395..0ee373296 100644 --- a/.dagger/go.mod +++ b/.dagger/go.mod @@ -1,6 +1,6 @@ module dagger/harbor-cli -go 1.25.0 +go 1.26.2 replace go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc => go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.14.0 diff --git a/.github/workflows/alauda-auto-tag.yml b/.github/workflows/alauda-auto-tag.yml new file mode 100644 index 000000000..c29fcea2d --- /dev/null +++ b/.github/workflows/alauda-auto-tag.yml @@ -0,0 +1,79 @@ +name: Auto Tag for Alauda + +on: + push: + branches: + - 'alauda-v*' + +permissions: + contents: write + +jobs: + tag: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Git + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + + - name: Extract version and tag prefix + id: extract + run: | + BRANCH_NAME="${GITHUB_REF#refs/heads/}" + echo "Branch: $BRANCH_NAME" + + PREFIX="${BRANCH_NAME%%-*}" # alauda + BASE_VERSION="${BRANCH_NAME#${PREFIX}-}" # v0.0.18 + + VERSION_NO_V="${BASE_VERSION#v}" # 0.0.18 + MAJOR=$(echo "$VERSION_NO_V" | cut -d. -f1) + MINOR=$(echo "$VERSION_NO_V" | cut -d. -f2) + PATCH=$(echo "$VERSION_NO_V" | cut -d. -f3) + + NEXT_PATCH=$((PATCH + 1)) + NEXT_VERSION="v${MAJOR}.${MINOR}.${NEXT_PATCH}" # v0.0.19 + + TAG_PREFIX="${NEXT_VERSION}-${PREFIX}" # v0.0.19-alauda + echo "TAG_PREFIX=$TAG_PREFIX" + + echo "tag_prefix=$TAG_PREFIX" >> $GITHUB_OUTPUT + + - name: Find latest tag with this prefix + id: latest + run: | + TAG_PREFIX="${{ steps.extract.outputs.tag_prefix }}" + echo "Looking for tags with prefix: $TAG_PREFIX" + + EXISTING_TAGS=$(git tag --list "${TAG_PREFIX}-*" | sort -V) + echo "Existing tags: $EXISTING_TAGS" + + MAX_INDEX=-1 + for tag in $EXISTING_TAGS; do + NUM=${tag##*-} + if [[ "$NUM" =~ ^[0-9]+$ && "$NUM" -gt "$MAX_INDEX" ]]; then + MAX_INDEX=$NUM + fi + done + + NEW_INDEX=$((MAX_INDEX + 1)) + NEW_TAG="${TAG_PREFIX}-${NEW_INDEX}" + + echo "new_tag=$NEW_TAG" >> $GITHUB_OUTPUT + + - name: Create and push new tag + run: | + NEW_TAG="${{ steps.latest.outputs.new_tag }}" + echo "Creating tag: $NEW_TAG" + git tag "$NEW_TAG" + git push origin "$NEW_TAG" + + release: + name: Release Alauda + needs: [tag] + uses: ./.github/workflows/release-alauda.yml diff --git a/.github/workflows/default.yaml b/.github/workflows/default.yaml index 2605d5015..1a0cc1927 100644 --- a/.github/workflows/default.yaml +++ b/.github/workflows/default.yaml @@ -278,12 +278,12 @@ jobs: id-token: write runs-on: ubuntu-latest if: | - (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) || + (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && !contains(github.ref, '-alauda-')) || (github.event_name == 'workflow_dispatch') steps: - name: Checkout repo if: | - (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) || + (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && !contains(github.ref, '-alauda-')) || (github.event_name == 'workflow_dispatch') uses: actions/checkout@v4 with: @@ -292,13 +292,13 @@ jobs: - name: Create Build Dir if: | - (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) || + (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && !contains(github.ref, '-alauda-')) || (github.event_name == 'workflow_dispatch') run: mkdir -p dist - name: Building Binaries if: | - (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) || + (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && !contains(github.ref, '-alauda-')) || (github.event_name == 'workflow_dispatch') uses: dagger/dagger-for-github@v7 with: @@ -308,7 +308,7 @@ jobs: - name: Archiving Binaries if: | - (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) || + (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && !contains(github.ref, '-alauda-')) || (github.event_name == 'workflow_dispatch') uses: dagger/dagger-for-github@v7 with: @@ -318,7 +318,7 @@ jobs: - name: Building SBOM if: | - (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) || + (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && !contains(github.ref, '-alauda-')) || (github.event_name == 'workflow_dispatch') uses: dagger/dagger-for-github@v7 with: @@ -328,7 +328,7 @@ jobs: - name: NFPM Build (deb/rpm) if: | - (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) || + (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && !contains(github.ref, '-alauda-')) || (github.event_name == 'workflow_dispatch') uses: dagger/dagger-for-github@v7 with: @@ -338,7 +338,7 @@ jobs: - name: APK Build (.apk) if: | - (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) || + (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && !contains(github.ref, '-alauda-')) || (github.event_name == 'workflow_dispatch') uses: dagger/dagger-for-github@v7 with: @@ -348,7 +348,7 @@ jobs: - name: Creating Checksum if: | - (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) || + (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && !contains(github.ref, '-alauda-')) || (github.event_name == 'workflow_dispatch') uses: dagger/dagger-for-github@v7 with: @@ -358,7 +358,7 @@ jobs: - name: Publish Release if: | - (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) || + (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && !contains(github.ref, '-alauda-')) || (github.event_name == 'workflow_dispatch') uses: dagger/dagger-for-github@v7 env: @@ -370,7 +370,7 @@ jobs: - name: Apt Build if: | - (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) || + (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && !contains(github.ref, '-alauda-')) || (github.event_name == 'workflow_dispatch') uses: dagger/dagger-for-github@v7 env: @@ -382,7 +382,7 @@ jobs: - name: Upload Build Artifact if: | - (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) || + (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && !contains(github.ref, '-alauda-')) || (github.event_name == 'workflow_dispatch') uses: actions/upload-artifact@v4 with: @@ -391,7 +391,7 @@ jobs: - name: Publish and Sign Tagged Image if: | - (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) || + (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && !contains(github.ref, '-alauda-')) || (github.event_name == 'workflow_dispatch') uses: ./.github/actions/publish-and-sign with: diff --git a/.github/workflows/release-alauda.yml b/.github/workflows/release-alauda.yml new file mode 100644 index 000000000..f5e6cf669 --- /dev/null +++ b/.github/workflows/release-alauda.yml @@ -0,0 +1,58 @@ +name: Release Alauda + +on: + push: + tags: + - "v*-alauda-*" + workflow_call: + workflow_dispatch: + +permissions: + contents: write + +jobs: + release: + name: alauda-release + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Dagger Version + id: dagger_version + uses: sagikazarmark/dagger-version-action@v0.0.1 + + - name: Create Build Dir + run: mkdir -p dist + + - name: Build Binaries + uses: dagger/dagger-for-github@v7 + with: + version: ${{ steps.dagger_version.outputs.version }} + verb: call + args: "build --build-dir=./dist export --path=./dist" + + - name: Archive Binaries + uses: dagger/dagger-for-github@v7 + with: + version: ${{ steps.dagger_version.outputs.version }} + verb: call + args: "archive --build-dir=./dist export --path=./dist" + + - name: Create Checksum + uses: dagger/dagger-for-github@v7 + with: + version: ${{ steps.dagger_version.outputs.version }} + verb: call + args: "checksum --build-dir=./dist export --path=./dist" + + - name: Publish Release + uses: dagger/dagger-for-github@v7 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + version: ${{ steps.dagger_version.outputs.version }} + verb: call + args: "publish-release --build-dir=./dist --token=env://GITHUB_TOKEN" diff --git a/go.mod b/go.mod index c8ec66bdb..f92aad1fb 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/goharbor/harbor-cli -go 1.24.8 +go 1.26.2 require ( github.com/atotto/clipboard v0.1.4 diff --git a/renovate.json b/renovate.json new file mode 100644 index 000000000..3be18a7b5 --- /dev/null +++ b/renovate.json @@ -0,0 +1,7 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": ["github>AlaudaDevops/renovate-config:base"], + "baseBranches": ["/^alauda-v.*/"], + "postUpdateOptions": ["gomodTidy"], + "assignees": ["chengjingtao"] +}