|
| 1 | +name: Init Argo CD Image Updater Release |
| 2 | +on: |
| 3 | + workflow_dispatch: |
| 4 | + inputs: |
| 5 | + TARGET_BRANCH: |
| 6 | + description: 'TARGET_BRANCH to checkout (e.g. release-0.14)' |
| 7 | + required: true |
| 8 | + type: string |
| 9 | + |
| 10 | + TARGET_VERSION: |
| 11 | + description: 'TARGET_VERSION to build manifests (e.g. 0.14.0-rc1) Note: the `v` prefix is not used' |
| 12 | + required: true |
| 13 | + type: string |
| 14 | + |
| 15 | +permissions: {} |
| 16 | + |
| 17 | +env: |
| 18 | + TARGET_REMOTE: upstream |
| 19 | + TARGET_TAG: "v${{ inputs.TARGET_VERSION }}" |
| 20 | + |
| 21 | +jobs: |
| 22 | + prepare-release: |
| 23 | + permissions: |
| 24 | + contents: write # for peter-evans/create-pull-request to create branch |
| 25 | + pull-requests: write # for peter-evans/create-pull-request to create a PR |
| 26 | + name: Automatically generate version and manifests on ${{ inputs.TARGET_BRANCH }} |
| 27 | + runs-on: ubuntu-22.04 |
| 28 | + steps: |
| 29 | + - name: Checkout code |
| 30 | + uses: actions/checkout@8410ad0602e1e429cee44a835ae9f77f654a6694 # v4.0.0 |
| 31 | + with: |
| 32 | + fetch-depth: 0 |
| 33 | + fetch-tags: true |
| 34 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 35 | + ref: ${{ inputs.TARGET_BRANCH }} |
| 36 | + |
| 37 | + - name: Check if TARGET_VERSION is well formed. |
| 38 | + run: | |
| 39 | + set -ue |
| 40 | + # Target version must not contain 'v' prefix |
| 41 | + if echo "${{ inputs.TARGET_VERSION }}" | grep -e '^v'; then |
| 42 | + echo "::error::Target version '${{ inputs.TARGET_VERSION }}' should not begin with a 'v' prefix, refusing to continue." >&2 |
| 43 | + exit 1 |
| 44 | + fi |
| 45 | + if ! echo "${{ inputs.TARGET_VERSION }}" | egrep -q '^[0-9]+\.[0-9]+\.[0-9]+$'; then |
| 46 | + echo "Error: Target version '${{ inputs.TARGET_VERSION }}' is not well-formed. Must be X.Y.Z" >&2 |
| 47 | + exit 1 |
| 48 | + fi |
| 49 | +
|
| 50 | + - name: Checking for current git branch |
| 51 | + run: | |
| 52 | + set -ue |
| 53 | + RELEASE_BRANCH=$(git rev-parse --abbrev-ref HEAD || true) |
| 54 | + if [[ $RELEASE_BRANCH = release-* ]]; then |
| 55 | + echo "*** branch is $RELEASE_BRANCH" |
| 56 | + else |
| 57 | + echo "Error: Branch $RELEASE_BRANCH is not release branch" >&2 |
| 58 | + exit 1 |
| 59 | + fi |
| 60 | +
|
| 61 | + - name: Checking for existence of git tag |
| 62 | + run: | |
| 63 | + set -ue |
| 64 | + if git show-ref --tags "${{ env.TARGET_TAG }}" --quiet; then |
| 65 | + echo "Error: Tag with version ${{ env.TARGET_TAG }} already exists." >&2 |
| 66 | + exit 1 |
| 67 | + fi |
| 68 | +
|
| 69 | + - name: Create VERSION information |
| 70 | + run: | |
| 71 | + set -ue |
| 72 | + if ! test -f VERSION; then |
| 73 | + echo "Error: You should be in repository root." >&2 |
| 74 | + exit 1 |
| 75 | + fi |
| 76 | + echo "Bumping version from $(cat VERSION) to ${{ inputs.TARGET_VERSION }}" |
| 77 | + echo "${{ inputs.TARGET_VERSION }}" > VERSION |
| 78 | +
|
| 79 | + - name: Install Kustomize |
| 80 | + uses: imranismail/setup-kustomize@v2 |
| 81 | + with: |
| 82 | + kustomize-version: '5.2.1' |
| 83 | + |
| 84 | + - name: Generate new set of manifests |
| 85 | + run: | |
| 86 | + set -ue |
| 87 | + echo kustomize version $(kustomize version) |
| 88 | + make manifests IMAGE_TAG="${{ env.TARGET_TAG }}" |
| 89 | + git diff |
| 90 | +
|
| 91 | + - name: Create pull request |
| 92 | + id: create-pull-request |
| 93 | + uses: peter-evans/create-pull-request@6d6857d36972b65feb161a90e484f2984215f83e # v6.0.5 |
| 94 | + with: |
| 95 | + commit-message: "Bump version to ${{ inputs.TARGET_VERSION }}" |
| 96 | + title: "Bump version to ${{ inputs.TARGET_VERSION }} on ${{ inputs.TARGET_BRANCH }} branch" |
| 97 | + body: Updating VERSION and manifests to ${{ inputs.TARGET_VERSION }} |
| 98 | + branch: update-version |
| 99 | + branch-suffix: random |
| 100 | + signoff: true |
| 101 | + labels: release |
| 102 | + |
| 103 | + - name: Next steps |
| 104 | + run: | |
| 105 | + echo "Created release PR: ${{ steps.create-pull-request.outputs.pull-request-url }}" |
| 106 | + echo "Once this PR is merged, pull from ${{ env.TARGET_REMOTE }} ${{ inputs.TARGET_BRANCH }}, tag the release, and build release artifacts." |
| 107 | + echo "If everything is fine, push changes to GitHub and container registry:" |
| 108 | + echo " git fetch ${{ env.TARGET_REMOTE }} ${{ inputs.TARGET_BRANCH }}" |
| 109 | + echo " git switch ${{ inputs.TARGET_BRANCH }}" |
| 110 | + echo " git pull ${{ env.TARGET_REMOTE }} ${{ inputs.TARGET_BRANCH }}" |
| 111 | + echo " git tag ${{ env.TARGET_TAG }}" |
| 112 | + echo " make multiarch-image" |
| 113 | + echo " make release-binaries" |
| 114 | + echo " git push ${{ env.TARGET_REMOTE }} ${{ inputs.TARGET_BRANCH }} ${{ env.TARGET_TAG }}" |
| 115 | + echo " make IMAGE_TAG='${{ env.TARGET_TAG }}' multiarch-image-push" |
| 116 | + echo |
| 117 | + echo "Then, create release tag and execute upload-multiarch-release-assets.sh" |
| 118 | +
|
| 119 | +
|
0 commit comments