From 7dfe89bf6e3a25e4ffc39e59a81a5822c8a7db48 Mon Sep 17 00:00:00 2001 From: Hui Yu Date: Tue, 10 May 2022 15:04:55 +0800 Subject: [PATCH 1/2] cicd: Add a Github action to release automatically --- .github/workflows/release.yml | 46 +++++++++++++++++++++++++ RELEASE.md | 63 ++++++++++++++++++++++++++++++++--- 2 files changed, 104 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..98310eda --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,46 @@ +name: Release + +on: + workflow_dispatch: + inputs: + releaseVersion: + type: string + required: true + description: The release version of this release. Must be a semantic version of the form X.Y.Z + dry-run: + type: boolean + required: true + description: Dry run, will not push tags to branch and release. + +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: Validate Input + run: | + echo "${{ github.ref_type }}" | perl -ne 'die unless m/^branch$/' + echo "${{ github.ref_name }}" | perl -ne 'die unless m/^release-\d+\.\d+$/' + echo "${{ github.event.inputs.releaseVersion }}" | perl -ne 'die unless m/^\d+\.\d+\.\d+$/' + - name: Checkout + uses: actions/checkout@v3 + - name: Check Actor + run: | + # Release actor should be in the OWNER list + cat OWNERS | grep ${{ github.actor }} + - name: Prepare + run: | + git config user.email "k8s.ci.robot@gmail.com" + git config user.name "Kubernetes Prow Robot" + - name: Release Prepare + run: | + git tag -a v${{ github.event.inputs.releaseVersion }} -m "version ${{ github.event.inputs.releaseVersion }}" + - name: Release Perform + if: ${{ github.event.inputs.dry-run != 'true' }} + run: | + git push https://${{ github.token }}@github.com/${{ github.repository }}.git v${{ github.event.inputs.releaseVersion }} + - name: Publish Release + if: ${{ github.event.inputs.dry-run != 'true' }} + uses: ncipollo/release-action@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + tag: v${{ github.event.inputs.releaseVersion }} \ No newline at end of file diff --git a/RELEASE.md b/RELEASE.md index bf135728..5c2e0203 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -2,9 +2,59 @@ The Kubernetes C Client Project is released on an as-needed basis. The process is as follows: -1. An issue is proposing a new release with a changelog since the last release -1. All [OWNERS](OWNERS) must LGTM this release -1. An OWNER runs `git tag -s $VERSION` or `git tag -a $VERSION` (If GPG-signed tag is not required) and inserts the changelog and pushes the tag with `git push origin $VERSION` +## Request + +An issue is proposing a new release with a changelog since the last release + +All [OWNERS](OWNERS) must LGTM this release + +## Prepare + +Before release, we need to determine our release branch. + +The release branch will always be of the form `release-.`. Any +time a `` or `` version number is incremented, a new release +branch needs to be created with `git checkout -b release-.` _from +the branch containing the changes you want to release_. If you are only +releasing bug fixes for an existing `.` release (a patch +release), you simply checkout that existing release branch `git checkout +release-.`. + +Now we are ready to perform the release. + +## Release + +There are 2 options to release: via Github Action or by manul + +### Release via Github Action + +Maintainers meeting the following requirements will be able to perform automated +release: + +* Has "collaborator" permission or higher (otherwise they can't run the job manually). +* Should be in the OWNERS file. + +#### Fill in the release workflow inputs manually + +The Github Action workflow [Release](https://github.com/kubernetes-client/c/actions/workflows/release.yml) will require three manual inputs: + +* The branch on which the workflow runs, must be a release branch, e.g. `release-X.Y` + +* The releasing version, must be a valid semver `X.Y.Z` (without "v" prefix). + +* Dry-Run: Indicating whether the release job will push the generated tag to the release branch and actually do a Github release. + +Fill in the inputs, then click "Run" to start the job. + +#### Release note, announcements + +After the release job successfully finishes, we're supposed to see a git tag `vX.Y.Z` pushed to the release branch, a GITHUB release will also be packed on the tag. + +In the end, don't forget to clarify the release notes on the GITHUB release. + +### Release by manual + +An OWNER runs `git tag -s $VERSION` or `git tag -a $VERSION` (If GPG-signed tag is not required) and inserts the changelog and pushes the tag with `git push origin $VERSION` e.g ```shell @@ -12,5 +62,8 @@ The Kubernetes C Client Project is released on an as-needed basis. The process i git push origin v0.1.0 ``` -1. The release issue is closed -1. An announcement email is sent to `kubernetes-dev@googlegroups.com` with the subject `[ANNOUNCE] kubernetes-template-project $VERSION is released` +## Announcement + +The release issue is closed + +An announcement email is sent to `kubernetes-dev@googlegroups.com` with the subject `[ANNOUNCE] kubernetes-template-project $VERSION is released` From c7d16dc3a7e695ca0f3e9a71da09ce5e9a968254 Mon Sep 17 00:00:00 2001 From: Hui Yu Date: Fri, 13 May 2022 14:07:15 +0800 Subject: [PATCH 2/2] Use GitHub CLI to release --- .github/workflows/release.yml | 8 ++++---- RELEASE.md | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 98310eda..7ebe0c3e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -40,7 +40,7 @@ jobs: git push https://${{ github.token }}@github.com/${{ github.repository }}.git v${{ github.event.inputs.releaseVersion }} - name: Publish Release if: ${{ github.event.inputs.dry-run != 'true' }} - uses: ncipollo/release-action@v1 - with: - token: ${{ secrets.GITHUB_TOKEN }} - tag: v${{ github.event.inputs.releaseVersion }} \ No newline at end of file + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh release create -d --generate-notes v${{ github.event.inputs.releaseVersion }} \ No newline at end of file diff --git a/RELEASE.md b/RELEASE.md index 5c2e0203..da077310 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -24,9 +24,9 @@ Now we are ready to perform the release. ## Release -There are 2 options to release: via Github Action or by manul +There are 2 options to release: via GitHub Action or by manul -### Release via Github Action +### Release via GitHub Action Maintainers meeting the following requirements will be able to perform automated release: @@ -36,21 +36,21 @@ release: #### Fill in the release workflow inputs manually -The Github Action workflow [Release](https://github.com/kubernetes-client/c/actions/workflows/release.yml) will require three manual inputs: +The GitHub Action workflow [Release](https://github.com/kubernetes-client/c/actions/workflows/release.yml) will require three manual inputs: * The branch on which the workflow runs, must be a release branch, e.g. `release-X.Y` * The releasing version, must be a valid semver `X.Y.Z` (without "v" prefix). -* Dry-Run: Indicating whether the release job will push the generated tag to the release branch and actually do a Github release. +* Dry-Run: Indicating whether the release job will push the generated tag to the release branch and actually do a GitHub release. Fill in the inputs, then click "Run" to start the job. #### Release note, announcements -After the release job successfully finishes, we're supposed to see a git tag `vX.Y.Z` pushed to the release branch, a GITHUB release will also be packed on the tag. +After the release job successfully finishes, we're supposed to see a git tag `vX.Y.Z` pushed to the release branch, a GitHub draft release will also be packed on the tag. -In the end, don't forget to clarify the release notes on the GITHUB release. +In the end, manually update the release notes and publish the release on the GitHub release page. ### Release by manual