-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Jian Qiu <jqiu@redhat.com>
- Loading branch information
Showing
8 changed files
with
331 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
name: GoRelease | ||
|
||
on: | ||
pull_request: | ||
paths: | ||
- .github/workflows/release.yml | ||
push: | ||
tags: | ||
- 'v*.*.*' | ||
env: | ||
GITHUB_REF: ${{ github.ref }} | ||
|
||
defaults: | ||
run: | ||
working-directory: go/src/open-cluster-management.io/ocm | ||
|
||
jobs: | ||
env: | ||
name: prepare release env | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: checkout code | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 1 | ||
path: go/src/open-cluster-management.io/ocm | ||
- 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 | ||
outputs: | ||
MAJOR_RELEASE_VERSION: ${{ env.MAJOR_RELEASE_VERSION }} | ||
RELEASE_VERSION: ${{ env.RELEASE_VERSION }} | ||
release: | ||
name: release | ||
runs-on: ubuntu-latest | ||
needs: [ env ] | ||
steps: | ||
- name: checkout code | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 1 | ||
path: go/src/open-cluster-management.io/ocm | ||
- name: Set up Python 3.x | ||
uses: actions/setup-python@v4 | ||
with: | ||
# Semantic version range syntax or exact version of a Python version | ||
python-version: '3.x' | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install PyGithub | ||
- name: generate changelog | ||
run: | | ||
python hack/changelog.py ${{ secrets.GITHUB_TOKEN }} ${{ needs.env.outputs.RELEASE_VERSION }} > /home/runner/work/changelog.txt | ||
- name: publish release | ||
if: github.event_name != 'pull_request' | ||
uses: softprops/action-gh-release@v0.1.5 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
body_path: /home/runner/work/changelog.txt | ||
draft: true | ||
generate_release_notes: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
name: GoRelease | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*.*.*' | ||
env: | ||
# Common versions | ||
GO_VERSION: '1.20' | ||
GO_REQUIRED_MIN_VERSION: '' | ||
GOPATH: '/home/runner/work/ocm/ocm/go' | ||
GITHUB_REF: ${{ github.ref }} | ||
|
||
defaults: | ||
run: | ||
working-directory: go/src/open-cluster-management.io/ocm | ||
|
||
jobs: | ||
env: | ||
name: prepare release env | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: checkout code | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 1 | ||
path: go/src/open-cluster-management.io/ocm | ||
- 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 | ||
outputs: | ||
MAJOR_RELEASE_VERSION: ${{ env.MAJOR_RELEASE_VERSION }} | ||
RELEASE_VERSION: ${{ env.RELEASE_VERSION }} | ||
images: | ||
name: images | ||
runs-on: ubuntu-latest | ||
needs: [ env ] | ||
strategy: | ||
matrix: | ||
arch: [ amd64, arm64 ] | ||
steps: | ||
- name: checkout code | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 1 | ||
path: go/src/open-cluster-management.io/ocm | ||
- name: install Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: ${{ env.GO_VERSION }} | ||
- name: install imagebuilder | ||
run: go install github.com/openshift/imagebuilder/cmd/imagebuilder@v1.2.3 | ||
- name: pull base image | ||
run: docker pull registry.access.redhat.com/ubi8/ubi-minimal:latest --platform=linux/${{ matrix.arch }} | ||
- name: images | ||
run: | | ||
IMAGE_TAG=${{ needs.env.outputs.RELEASE_VERSION }}-${{ matrix.arch }} \ | ||
IMAGE_BUILD_EXTRA_FLAGS="--build-arg OS=linux --build-arg ARCH=${{ matrix.arch }}" \ | ||
make images | ||
- name: push | ||
run: | | ||
echo ${{ secrets.DOCKER_PASSWORD }} | docker login quay.io --username ${{ secrets.DOCKER_USER }} --password-stdin | ||
docker push quay.io/open-cluster-management/registration:${{ needs.env.outputs.RELEASE_VERSION }}-${{ matrix.arch }} | ||
docker push quay.io/open-cluster-management/work:${{ needs.env.outputs.RELEASE_VERSION }}-${{ matrix.arch }} | ||
docker push quay.io/open-cluster-management/placement:${{ needs.env.outputs.RELEASE_VERSION }}-${{ matrix.arch }} | ||
docker push quay.io/open-cluster-management/registration-operator:${{ needs.env.outputs.RELEASE_VERSION }}-${{ matrix.arch }} | ||
docker push quay.io/open-cluster-management/addon-manager:${{ needs.env.outputs.RELEASE_VERSION }}-${{ matrix.arch }} | ||
image-manifest: | ||
name: image manifest | ||
runs-on: ubuntu-latest | ||
needs: [ env, images ] | ||
steps: | ||
- name: create | ||
run: | | ||
echo ${{ secrets.DOCKER_PASSWORD }} | docker login quay.io --username ${{ secrets.DOCKER_USER }} --password-stdin | ||
# registration | ||
docker manifest create quay.io/open-cluster-management/registration:${{ needs.env.outputs.RELEASE_VERSION }} \ | ||
quay.io/open-cluster-management/registration:${{ needs.env.outputs.RELEASE_VERSION }}-amd64 \ | ||
quay.io/open-cluster-management/registration:${{ needs.env.outputs.RELEASE_VERSION }}-arm64 | ||
# work | ||
docker manifest create quay.io/open-cluster-management/work:${{ needs.env.outputs.RELEASE_VERSION }} \ | ||
quay.io/open-cluster-management/work:${{ needs.env.outputs.RELEASE_VERSION }}-amd64 \ | ||
quay.io/open-cluster-management/work:${{ needs.env.outputs.RELEASE_VERSION }}-arm64 | ||
# placement | ||
docker manifest create quay.io/open-cluster-management/placement:${{ needs.env.outputs.RELEASE_VERSION }} \ | ||
quay.io/open-cluster-management/placement:${{ needs.env.outputs.RELEASE_VERSION }}-amd64 \ | ||
quay.io/open-cluster-management/placement:${{ needs.env.outputs.RELEASE_VERSION }}-arm64 | ||
# addon-manager | ||
docker manifest create quay.io/open-cluster-management/addon-manager:${{ needs.env.outputs.RELEASE_VERSION }} \ | ||
quay.io/open-cluster-management/addon-manager:${{ needs.env.outputs.RELEASE_VERSION }}-amd64 \ | ||
quay.io/open-cluster-management/addon-manager:${{ needs.env.outputs.RELEASE_VERSION }}-arm64 | ||
# registration-operator | ||
docker manifest create quay.io/open-cluster-management/registration-operator:${{ needs.env.outputs.RELEASE_VERSION }} \ | ||
quay.io/open-cluster-management/registration-operator:${{ needs.env.outputs.RELEASE_VERSION }}-amd64 \ | ||
quay.io/open-cluster-management/registration-operator:${{ needs.env.outputs.RELEASE_VERSION }}-arm64 | ||
- name: annotate | ||
run: | | ||
# registration | ||
docker manifest annotate quay.io/open-cluster-management/registration:${{ needs.env.outputs.RELEASE_VERSION }} \ | ||
quay.io/open-cluster-management/registration:${{ needs.env.outputs.RELEASE_VERSION }}-amd64 --arch amd64 | ||
docker manifest annotate quay.io/open-cluster-management/registration:${{ needs.env.outputs.RELEASE_VERSION }} \ | ||
quay.io/open-cluster-management/registration:${{ needs.env.outputs.RELEASE_VERSION }}-arm64 --arch arm64 | ||
# work | ||
docker manifest annotate quay.io/open-cluster-management/work:${{ needs.env.outputs.RELEASE_VERSION }} \ | ||
quay.io/open-cluster-management/work:${{ needs.env.outputs.RELEASE_VERSION }}-amd64 --arch amd64 | ||
docker manifest annotate quay.io/open-cluster-management/work:${{ needs.env.outputs.RELEASE_VERSION }} \ | ||
quay.io/open-cluster-management/work:${{ needs.env.outputs.RELEASE_VERSION }}-arm64 --arch arm64 | ||
# placement | ||
docker manifest annotate quay.io/open-cluster-management/placement:${{ needs.env.outputs.RELEASE_VERSION }} \ | ||
quay.io/open-cluster-management/placement:${{ needs.env.outputs.RELEASE_VERSION }}-amd64 --arch amd64 | ||
docker manifest annotate quay.io/open-cluster-management/placement:${{ needs.env.outputs.RELEASE_VERSION }} \ | ||
quay.io/open-cluster-management/placement:${{ needs.env.outputs.RELEASE_VERSION }}-arm64 --arch arm64 | ||
# addon-manager | ||
docker manifest annotate quay.io/open-cluster-management/addon-manager:${{ needs.env.outputs.RELEASE_VERSION }} \ | ||
quay.io/open-cluster-management/addon-manager:${{ needs.env.outputs.RELEASE_VERSION }}-amd64 --arch amd64 | ||
docker manifest annotate quay.io/open-cluster-management/addon-manager:${{ needs.env.outputs.RELEASE_VERSION }} \ | ||
quay.io/open-cluster-management/addon-manager:${{ needs.env.outputs.RELEASE_VERSION }}-arm64 --arch arm64 | ||
# registration-operator | ||
docker manifest annotate quay.io/open-cluster-management/registration-operator:${{ needs.env.outputs.RELEASE_VERSION }} \ | ||
quay.io/open-cluster-management/registration-operator:${{ needs.env.outputs.RELEASE_VERSION }}-amd64 --arch amd64 | ||
docker manifest annotate quay.io/open-cluster-management/registration-operator:${{ needs.env.outputs.RELEASE_VERSION }} \ | ||
quay.io/open-cluster-management/registration-operator:${{ needs.env.outputs.RELEASE_VERSION }}-arm64 --arch arm64 | ||
- name: push | ||
run: | | ||
docker manifest push quay.io/open-cluster-management/registration:${{ needs.env.outputs.RELEASE_VERSION }} | ||
docker manifest push quay.io/open-cluster-management/work:${{ needs.env.outputs.RELEASE_VERSION }} | ||
docker manifest push quay.io/open-cluster-management/placement:${{ needs.env.outputs.RELEASE_VERSION }} | ||
docker manifest push quay.io/open-cluster-management/addon-manager:${{ needs.env.outputs.RELEASE_VERSION }} | ||
docker manifest push quay.io/open-cluster-management/registration-operator:${{ needs.env.outputs.RELEASE_VERSION }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,5 +70,5 @@ spec: | |
initialDelaySeconds: 2 | ||
resources: | ||
requests: | ||
cpu: 100m | ||
memory: 128Mi | ||
cpu: 2m | ||
memory: 16Mi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
import sys | ||
|
||
from enum import Enum | ||
from github import Github | ||
from github import Auth | ||
|
||
emojiFeature = str('✨') | ||
emojiBugfix = str('🐛') | ||
emojiDocs = str('📖') | ||
emojiInfra = str('🌱') | ||
emojiBreaking = str('⚠') | ||
|
||
|
||
class PRType(Enum): | ||
UncategorizedPR = 1 | ||
BreakingPR = 2 | ||
FeaturePR = 3 | ||
BugfixPR = 4 | ||
DocsPR = 5 | ||
InfraPR = 6 | ||
|
||
|
||
def pr_type_from_title(pr_title: str): | ||
t = pr_title.strip() | ||
if len(pr_title) == 0: | ||
return PRType.UncategorizedPR, t | ||
|
||
if pr_title.startswith(':sparkles:') or pr_title.startswith(emojiFeature): | ||
return PRType.FeaturePR, t | ||
elif pr_title.startswith(':bug:') or pr_title.startswith(emojiBugfix): | ||
return PRType.BugfixPR, t | ||
elif pr_title.startswith(':book:') or pr_title.startswith(emojiDocs): | ||
return PRType.DocsPR, t | ||
elif pr_title.startswith(':seedling:') or pr_title.startswith(emojiInfra): | ||
return PRType.InfraPR, t | ||
elif pr_title.startswith(':warning:') or pr_title.startswith(emojiBreaking): | ||
return PRType.BreakingPR, t | ||
|
||
return PRType.UncategorizedPR, t | ||
|
||
|
||
def change_entry(pr_title, number, author): | ||
return "%s (#%d) @%s" % (pr_title, number, author) | ||
|
||
|
||
def section_if_present(changes: [], pr_title): | ||
if len(changes) > 0: | ||
print("") | ||
print("## %s\n" % pr_title) | ||
print("") | ||
for change in changes: | ||
print("- %s\n" % change) | ||
|
||
|
||
if __name__ == '__main__': | ||
args = sys.argv[1:] | ||
auth = Auth.Token(args[0]) | ||
release_tag = args[1] | ||
g = Github(auth=auth) | ||
repo = g.get_repo("open-cluster-management-io/ocm") | ||
pulls = repo.get_pulls(state='closed', sort='created', base='main', direction='desc') | ||
|
||
# get the last release tag | ||
tags = repo.get_tags() | ||
if tags.totalCount == 0: | ||
print("no tags in the repo") | ||
sys.exit() | ||
elif tags.totalCount == 1: | ||
last_release_tag = tags[0].name | ||
else: | ||
last_release_tag = tags[1].name | ||
|
||
# get related PR from the last release tag | ||
last_release_pr = 0 | ||
for tag in tags: | ||
if tag.name == last_release_tag: | ||
tag_pulls = tag.commit.get_pulls() | ||
last_release_pr = tag_pulls[0].number | ||
break | ||
|
||
# collect all PRs from the last release tag | ||
features = [] | ||
bugs = [] | ||
breakings = [] | ||
docs = [] | ||
infras = [] | ||
uncategorized = [] | ||
for pr in pulls: | ||
if pr.number == last_release_pr: | ||
break | ||
if pr.is_merged(): | ||
prtype, title = pr_type_from_title(pr.title) | ||
if prtype == PRType.FeaturePR: | ||
features.append(change_entry(title, pr.number, pr.user.login)) | ||
elif prtype == PRType.BugfixPR: | ||
bugs.append(change_entry(title, pr.number, pr.user.login)) | ||
elif prtype == PRType.DocsPR: | ||
docs.append(change_entry(title, pr.number, pr.user.login)) | ||
elif prtype == PRType.InfraPR: | ||
infras.append(change_entry(title, pr.number, pr.user.login)) | ||
elif prtype == PRType.BreakingPR: | ||
breakings.append(change_entry(title, pr.number, pr.user.login)) | ||
elif prtype == PRType.UncategorizedPR: | ||
uncategorized.append(change_entry(title, pr.number, pr.user.login)) | ||
|
||
print("# Open Cluster Management %s" % release_tag) | ||
print("\n**changes since [%s](https://github.com/open-cluster-management-io/releases/%s)**\n" | ||
% (last_release_tag, last_release_tag)) | ||
section_if_present(breakings, ":warning: Breaking Changes") | ||
section_if_present(features, ":sparkles: New Features") | ||
section_if_present(bugs, ":bug: Bug Fixes") | ||
section_if_present(docs, ":book: Documentation") | ||
section_if_present(infras, ":seedling: Infra & Such") | ||
print("") | ||
print("Thanks to all our contributors!*") |