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 Nov 11, 2024
2 parents dc4b18b + 49dcd46 commit 37a7b41
Show file tree
Hide file tree
Showing 24 changed files with 560 additions and 347 deletions.
24 changes: 24 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
version: 2
updates:
- package-ecosystem: gomod
directory: "/"
schedule:
interval: daily
commit-message:
prefix: ":seedling:"
open-pull-requests-limit: 3
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
commit-message:
prefix: ":seedling:"
groups:
github-actions:
patterns:
- "*"
# These actions directly influence the build process and are excluded from grouped updates
exclude-patterns:
- "actions/setup-go"
- "arduino/setup-protoc"
- "goreleaser/goreleaser-action"
62 changes: 62 additions & 0 deletions .github/workflows/chart-upload.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: ChartUpload

permissions:
contents: read

on:
release:
types: [published]

env:
CHART_NAME: managed-serviceaccount

jobs:
env:
name: prepare release env
runs-on: ubuntu-latest
steps:
- name: checkout code
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: get release version
id: get_release_version
run: |
RELEASE_VERSION=${GITHUB_REF#refs/tags/}
echo "::set-output name=RELEASE_VERSION::${RELEASE_VERSION}"
echo "::set-output name=MAJOR_RELEASE_VERSION::${RELEASE_VERSION%.*}"
echo "::set-output name=TRIMMED_RELEASE_VERSION::${RELEASE_VERSION#v}"
outputs:
RELEASE_VERSION: ${{ steps.get_release_version.outputs.RELEASE_VERSION }}
MAJOR_RELEASE_VERSION: ${{ steps.get_release_version.outputs.MAJOR_RELEASE_VERSION }}
TRIMMED_RELEASE_VERSION: ${{ steps.get_release_version.outputs.TRIMMED_RELEASE_VERSION }}
upload:
name: upload
runs-on: ubuntu-latest
needs: [ env ]
permissions:
contents: write
steps:
- name: submit charts to OCM chart repo
if: github.event_name != 'pull_request'
uses: actions/github-script@v7
with:
github-token: ${{ secrets.OCM_BOT_PAT }}
script: |
try {
const result = await github.rest.actions.createWorkflowDispatch({
owner: 'open-cluster-management-io',
repo: 'helm-charts',
workflow_id: 'download-chart.yml',
ref: 'main',
inputs: {
repo: "${{ github.repository }}",
version: "${{ needs.env.outputs.TRIMMED_RELEASE_VERSION }}",
"chart-name": "${{ env.CHART_NAME }}",
},
})
console.log(result);
} catch(error) {
console.error(error);
core.setFailed(error);
}
8 changes: 4 additions & 4 deletions .github/workflows/go-postsubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:

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

Expand All @@ -31,13 +31,13 @@ jobs:
fetch-depth: 1
path: go/src/open-cluster-management.io/managed-serviceaccount
- name: install Go
uses: actions/setup-go@v2
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: install imagebuilder
run: go install github.com/openshift/imagebuilder/cmd/[email protected]
- name: pull base image
run: docker pull registry.access.redhat.com/ubi8/ubi-minimal:latest --platform=linux/${{ matrix.arch }}
run: docker pull registry.access.redhat.com/ubi9/ubi-minimal:latest --platform=linux/${{ matrix.arch }}
- name: images
run: |
IMAGE_TAG=latest-${{ matrix.arch }} \
Expand Down Expand Up @@ -71,4 +71,4 @@ jobs:
quay.io/open-cluster-management/managed-serviceaccount:latest-arm64 --arch arm64
- name: push
run: |
docker manifest push quay.io/open-cluster-management/managed-serviceaccount:latest
docker manifest push quay.io/open-cluster-management/managed-serviceaccount:latest
21 changes: 11 additions & 10 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.21'
GO_VERSION: '1.22'
GO_REQUIRED_MIN_VERSION: ''

jobs:
Expand All @@ -24,7 +24,7 @@ jobs:
- name: checkout code
uses: actions/checkout@v4
- name: install Go
uses: actions/setup-go@v2
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: build
Expand All @@ -37,19 +37,20 @@ jobs:
- name: checkout code
uses: actions/checkout@v4
- name: install Go
uses: actions/setup-go@v2
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: unit
run: make test
- name: report coverage
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_UPLOAD_TOKEN }}
files: ./cover.out
flags: unit
name: unit
verbose: true
fail_ci_if_error: false
fail_ci_if_error: true

integration:
name: integration
Expand All @@ -58,7 +59,7 @@ jobs:
- name: checkout code
uses: actions/checkout@v4
- name: install Go
uses: actions/setup-go@v2
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: integration
Expand All @@ -71,13 +72,13 @@ jobs:
- name: checkout code
uses: actions/checkout@v4
- name: install Go
uses: actions/setup-go@v2
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Install clusteradm
run: curl -L https://raw.githubusercontent.com/open-cluster-management-io/clusteradm/main/install.sh | bash
- name: Create k8s Kind Cluster
uses: helm/kind-action@v1.2.0
uses: helm/kind-action@v1.10.0
- name: Prepare OCM testing environment
run: |
clusteradm init --output-join-command-file join.sh --wait
Expand Down Expand Up @@ -105,7 +106,7 @@ jobs:
- name: checkout code
uses: actions/checkout@v4
- name: install Go
uses: actions/setup-go@v2
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Install clusteradm
Expand All @@ -114,7 +115,7 @@ jobs:
cd clusteradm
make build
- name: Create k8s Kind Cluster
uses: helm/kind-action@v1.2.0
uses: helm/kind-action@v1.10.0
- name: Prepare OCM testing environment
run: |
clusteradm init --bundle-version='latest' --output-join-command-file join.sh --wait
Expand Down
99 changes: 5 additions & 94 deletions .github/workflows/go-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ on:
- 'v*.*.*'
env:
# Common versions
GO_VERSION: '1.21'
GO_VERSION: '1.22'
GO_REQUIRED_MIN_VERSION: ''
GITHUB_REF: ${{ github.ref }}
CHART_NAME: managed-serviceaccount
CHART_VERSION_FILE_PATH: ./charts/managed-serviceaccount/Chart.yaml

jobs:
env:
Expand Down Expand Up @@ -45,13 +44,13 @@ jobs:
with:
fetch-depth: 1
- name: install Go
uses: actions/setup-go@v2
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: install imagebuilder
run: go install github.com/openshift/imagebuilder/cmd/[email protected]
- name: pull base image
run: docker pull registry.access.redhat.com/ubi8/ubi-minimal:latest --platform=linux/${{ matrix.arch }}
run: docker pull registry.access.redhat.com/ubi9/ubi-minimal:latest --platform=linux/${{ matrix.arch }}
- name: images
run: |
IMAGE_TAG=${{ needs.env.outputs.RELEASE_VERSION }}-${{ matrix.arch }} \
Expand Down Expand Up @@ -95,7 +94,7 @@ jobs:
with:
fetch-depth: 1
- name: setup helm
uses: azure/setup-helm@v1
uses: azure/setup-helm@v4
- name: chart package
run: |
mkdir -p release
Expand All @@ -106,7 +105,7 @@ jobs:
run: |
echo "# Managed ServiceAccount ${{ needs.env.outputs.RELEASE_VERSION }}" > /home/runner/work/changelog.txt
- name: publish release
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
Expand All @@ -116,91 +115,3 @@ jobs:
draft: true
prerelease: false
generate_release_notes: true
- name: submit charts to OCM chart repo
uses: actions/github-script@v6
with:
github-token: ${{ secrets.OCM_BOT_PAT }}
script: |
try {
const result = await github.rest.actions.createWorkflowDispatch({
owner: 'open-cluster-management-io',
repo: 'helm-charts',
workflow_id: 'download-chart.yml',
ref: 'main',
inputs: {
repo: "${{ github.repository }}",
version: "${{ needs.env.outputs.TRIMMED_RELEASE_VERSION }}",
"chart-name": "${{ env.CHART_NAME }}",
},
})
console.log(result);
} catch(error) {
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 }}
Loading

0 comments on commit 37a7b41

Please sign in to comment.