Skip to content

Commit

Permalink
Merge branch 'open-cluster-management-io:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
zhujian7 authored Apr 18, 2024
2 parents d31c0fa + 4f583e2 commit b89880f
Show file tree
Hide file tree
Showing 17 changed files with 520 additions and 485 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/go-postsubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ on:

env:
# Common versions
GO_VERSION: '1.20'
GO_VERSION: '1.21'
GO_REQUIRED_MIN_VERSION: ''
GOPATH: '/home/runner/work/managed-serviceaccount/managed-serviceaccount/go'

defaults:
run:
working-directory: go/src/open-cluster-management.io/managed-serviceaccount
Expand All @@ -25,7 +26,7 @@ jobs:
arch: [ amd64, arm64 ]
steps:
- name: checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 1
path: go/src/open-cluster-management.io/managed-serviceaccount
Expand All @@ -52,7 +53,7 @@ jobs:
needs: [ images ]
steps:
- name: checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 1
path: go/src/open-cluster-management.io/managed-serviceaccount
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/go-presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:

env:
# Common versions
GO_VERSION: '1.20'
GO_VERSION: '1.21'
GO_REQUIRED_MIN_VERSION: ''

jobs:
Expand All @@ -22,7 +22,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: install Go
uses: actions/setup-go@v2
with:
Expand All @@ -35,7 +35,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: install Go
uses: actions/setup-go@v2
with:
Expand All @@ -49,14 +49,14 @@ jobs:
flags: unit
name: unit
verbose: true
fail_ci_if_error: true
fail_ci_if_error: false

integration:
name: integration
runs-on: ubuntu-latest
steps:
- name: checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: install Go
uses: actions/setup-go@v2
with:
Expand All @@ -69,7 +69,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: install Go
uses: actions/setup-go@v2
with:
Expand Down Expand Up @@ -104,7 +104,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: install Go
uses: actions/setup-go@v2
with:
Expand Down
94 changes: 76 additions & 18 deletions .github/workflows/go-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,32 @@ on:
- 'v*.*.*'
env:
# Common versions
GO_VERSION: '1.20'
GO_VERSION: '1.21'
GO_REQUIRED_MIN_VERSION: ''
GOPATH: '/home/runner/work/managed-serviceaccount/managed-serviceaccount/go'
GITHUB_REF: ${{ github.ref }}
CHART_NAME: managed-serviceaccount

defaults:
run:
working-directory: go/src/open-cluster-management.io/managed-serviceaccount
CHART_VERSION_FILE_PATH: ./charts/managed-serviceaccount/Chart.yaml

jobs:
env:
name: prepare release env
runs-on: ubuntu-latest
steps:
- name: checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 1
path: go/src/open-cluster-management.io/managed-serviceaccount
- name: get release version
run: |
echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- name: get major release version
run: |
echo "MAJOR_RELEASE_VERSION=${RELEASE_VERSION%.*}" >> $GITHUB_ENV
echo "TRIMED_RELEASE_VERSION=${RELEASE_VERSION#v}" >> $GITHUB_ENV
echo "TRIMMED_RELEASE_VERSION=${RELEASE_VERSION#v}" >> $GITHUB_ENV
outputs:
MAJOR_RELEASE_VERSION: ${{ env.MAJOR_RELEASE_VERSION }}
RELEASE_VERSION: ${{ env.RELEASE_VERSION }}
TRIMED_RELEASE_VERSION: ${{ env.TRIMED_RELEASE_VERSION }}
TRIMMED_RELEASE_VERSION: ${{ env.TRIMMED_RELEASE_VERSION }}
images:
name: images
runs-on: ubuntu-latest
Expand All @@ -46,10 +41,9 @@ jobs:
arch: [ amd64, arm64 ]
steps:
- name: checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 1
path: go/src/open-cluster-management.io/managed-serviceaccount
- name: install Go
uses: actions/setup-go@v2
with:
Expand All @@ -73,10 +67,9 @@ jobs:
needs: [ env, images ]
steps:
- name: checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 1
path: go/src/open-cluster-management.io/managed-serviceaccount
- name: create
run: |
echo ${{ secrets.DOCKER_PASSWORD }} | docker login quay.io --username ${{ secrets.DOCKER_USER }} --password-stdin
Expand All @@ -98,10 +91,9 @@ jobs:
needs: [ env, image-manifest ]
steps:
- name: checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 1
path: go/src/open-cluster-management.io/managed-serviceaccount
- name: setup helm
uses: azure/setup-helm@v1
- name: chart package
Expand All @@ -120,7 +112,7 @@ jobs:
with:
body_path: /home/runner/work/changelog.txt
files: |
go/src/open-cluster-management.io/managed-serviceaccount/release/*.tgz
release/*.tgz
draft: true
prerelease: false
generate_release_notes: true
Expand All @@ -137,7 +129,7 @@ jobs:
ref: 'main',
inputs: {
repo: "${{ github.repository }}",
version: "${{ needs.env.outputs.TRIMED_RELEASE_VERSION }}",
version: "${{ needs.env.outputs.TRIMMED_RELEASE_VERSION }}",
"chart-name": "${{ env.CHART_NAME }}",
},
})
Expand All @@ -146,3 +138,69 @@ jobs:
console.error(error);
core.setFailed(error);
}
increase-chart-version:
runs-on: ubuntu-latest
needs: [ env, release ]
steps:
- name: checkout code
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: calculate next version
id: calculate_next_version
run: |
echo "Current version: $CURRENT_VERSION"
# Extract the major and minor version components
MAJOR=$(echo $CURRENT_VERSION | cut -d '.' -f 1)
MINOR=$(echo $CURRENT_VERSION | cut -d '.' -f 2)
# Increment the minor version
NEXT_MINOR=$((MINOR + 1))
# Construct the next version
NEXT_VERSION="$MAJOR.$NEXT_MINOR.0"
echo "next_version=$NEXT_VERSION" >> $GITHUB_OUTPUT
env:
CURRENT_VERSION: ${{ needs.env.outputs.TRIMMED_RELEASE_VERSION }}

- name: update chart version file
id: update_chart_version
run: |
echo "Updating chart version file from $CURRENT_VERSION to $NEXT_VERSION"
sed -i "s/version: $CURRENT_VERSION/version: $NEXT_VERSION/" ${{ env.CHART_VERSION_FILE_PATH }}
git diff
FILE_CHANGED=$(git diff --exit-code --quiet && echo false || echo true)
echo "Chart version file changed: $FILE_CHANGED"
echo "file_changed=$FILE_CHANGED" >> $GITHUB_OUTPUT
env:
CURRENT_VERSION: ${{ needs.env.outputs.TRIMMED_RELEASE_VERSION }}
NEXT_VERSION: ${{ steps.calculate_next_version.outputs.next_version }}

- name: check if pull request already exists
id: check_pull_request
if : steps.update_chart_version.outputs.file_changed == 'true'
run: |
gh pr list --state open > pr_list.txt
cat pr_list.txt
PR_EXIST=$(grep -q "Update chart version to ${{ steps.calculate_next_version.outputs.next_version }}" pr_list.txt && echo true || echo false)
echo "pr_exists=$PR_EXIST" >> $GITHUB_OUTPUT
echo "Pull request for version ${{ steps.calculate_next_version.outputs.next_version }} exists: $PR_EXIST"
rm -rf pr_list.txt
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: create pull request
if: steps.update_chart_version.outputs.file_changed == 'true' && steps.check_pull_request.outputs.pr_exists != 'true'
uses: peter-evans/create-pull-request@v6
with:
# use OCM bot token to bypass "GitHub Actions is not permitted to create or approve pull requests."
token: ${{ secrets.OCM_BOT_PAT }}
commit-message: |
Update chart version to ${{ steps.calculate_next_version.outputs.next_version }}
title: ":seedling: Update chart version to ${{ steps.calculate_next_version.outputs.next_version }}"
body: "Automatically updating chart version to ${{ steps.calculate_next_version.outputs.next_version }}"
branch: update-chart-version-${{ steps.calculate_next_version.outputs.next_version }}
signoff: true
base: main
env:
CURRENT_VERSION: ${{ needs.env.outputs.TRIMMED_RELEASE_VERSION }}
NEXT_VERSION: ${{ steps.calculate_next_version.outputs.next_version }}
6 changes: 6 additions & 0 deletions .github/workflows/pr-verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ on:
# main branch.
pull_request_target:
types: [opened, edited, reopened, synchronize]
branches:
- main
- release-*

permissions:
contents: read

jobs:
verify:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.20-bullseye AS builder
FROM golang:1.21-bullseye AS builder
WORKDIR /go/src/github.com/open-cluster-management.io/managed-serviceaccount
COPY . .
RUN go env
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
IMG_REGISTRY ?= quay.io/open-cluster-management
IMAGE_TAG ?= latest
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
CRD_OPTIONS ?= "crd:trivialVersions=true,preserveUnknownFields=false"
CRD_OPTIONS ?= "crd:crdVersions={v1},allowDangerousTypes=true,generateEmbeddedObjectMeta=true"
E2E_TEST_CLUSTER_NAME ?= loopback

# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
Expand Down Expand Up @@ -95,7 +95,7 @@ undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/confi

CONTROLLER_GEN = $(shell pwd)/bin/controller-gen
controller-gen: ## Download controller-gen locally if necessary.
$(call go-get-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/controller-gen@v0.6.2)
$(call go-get-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/controller-gen@v0.14.0)

KUSTOMIZE = $(shell pwd)/bin/kustomize
kustomize: ## Download kustomize locally if necessary.
Expand Down Expand Up @@ -125,7 +125,7 @@ test-e2e: build-e2e
./bin/e2e --test-cluster $(E2E_TEST_CLUSTER_NAME) $(GENKGO_ARGS)

client-gen:
go install k8s.io/code-generator/cmd/client-gen@v0.27.4
go install k8s.io/code-generator/cmd/client-gen@v0.29.2
client-gen --go-header-file hack/boilerplate.go.txt --clientset-name versioned \
--output-base ./_output/gen \
--output-package open-cluster-management.io/managed-serviceaccount/pkg/generated/clientset \
Expand Down
1 change: 0 additions & 1 deletion apis/authentication/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion apis/authentication/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion charts/managed-serviceaccount/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ apiVersion: v2
name: managed-serviceaccount
description: A Helm chart for Managed ServiceAccount Addon
type: application
version: 0.4.0
version: 0.5.0
appVersion: 1.0.0
Loading

0 comments on commit b89880f

Please sign in to comment.