github.com/giantswarm/apiextensions/v6@v6.6.0/.github/workflows/zz_generated.create_release.yaml (about) 1 # DO NOT EDIT. Generated with: 2 # 3 # devctl@5.8.0 4 # 5 name: Create Release 6 on: 7 push: 8 branches: 9 - 'legacy' 10 - 'main' 11 - 'master' 12 - 'release-v*.*.x' 13 # "!" negates previous positive patterns so it has to be at the end. 14 - '!release-v*.x.x' 15 jobs: 16 debug_info: 17 name: Debug info 18 runs-on: ubuntu-20.04 19 steps: 20 - name: Print github context JSON 21 run: | 22 cat <<EOF 23 ${{ toJson(github) }} 24 EOF 25 gather_facts: 26 name: Gather facts 27 runs-on: ubuntu-20.04 28 outputs: 29 project_go_path: ${{ steps.get_project_go_path.outputs.path }} 30 ref_version: ${{ steps.ref_version.outputs.refversion }} 31 version: ${{ steps.get_version.outputs.version }} 32 steps: 33 - name: Get version 34 id: get_version 35 run: | 36 title="$(cat <<- 'COMMIT_MESSAGE_END' | head -n 1 - 37 ${{ github.event.head_commit.message }} 38 COMMIT_MESSAGE_END 39 )" 40 # Matches strings like: 41 # 42 # - "Release v1.2.3" 43 # - "Release v1.2.3-r4" 44 # - "Release v1.2.3 (#56)" 45 # - "Release v1.2.3-r4 (#56)" 46 # 47 # And outputs version part (1.2.3). 48 if echo "${title}" | grep -iqE '^Release v[0-9]+\.[0-9]+\.[0-9]+([.-][^ .-][^ ]*)?( \(#[0-9]+\))?$' ; then 49 version=$(echo "${title}" | cut -d ' ' -f 2) 50 fi 51 version="${version#v}" # Strip "v" prefix. 52 echo "version=\"${version}\"" 53 echo "::set-output name=version::${version}" 54 - name: Checkout code 55 if: ${{ steps.get_version.outputs.version != '' }} 56 uses: actions/checkout@v3 57 - name: Get project.go path 58 id: get_project_go_path 59 if: ${{ steps.get_version.outputs.version != '' }} 60 run: | 61 path='./pkg/project/project.go' 62 if [[ ! -f $path ]] ; then 63 path='' 64 fi 65 echo "path=\"$path\"" 66 echo "::set-output name=path::${path}" 67 - name: Check if reference version 68 id: ref_version 69 run: | 70 title="$(cat <<- 'COMMIT_MESSAGE_END' | head -n 1 - 71 ${{ github.event.head_commit.message }} 72 COMMIT_MESSAGE_END 73 )" 74 if echo "${title}" | grep -qE '^release v[0-9]+\.[0-9]+\.[0-9]+([.-][^ .-][^ ]*)?( \(#[0-9]+\))?$' ; then 75 version=$(echo "${title}" | cut -d ' ' -f 2) 76 fi 77 version=$(echo "${title}" | cut -d ' ' -f 2) 78 version="${version#v}" # Strip "v" prefix. 79 refversion=false 80 if [[ "${version}" =~ ^[0-9]+.[0-9]+.[0-9]+-[0-9]+$ ]]; then 81 refversion=true 82 fi 83 echo "refversion =\"${refversion}\"" 84 echo "::set-output name=refversion::${refversion}" 85 update_project_go: 86 name: Update project.go 87 runs-on: ubuntu-20.04 88 if: ${{ needs.gather_facts.outputs.version != '' && needs.gather_facts.outputs.project_go_path != '' && needs.gather_facts.outputs.ref_version != 'true' }} 89 needs: 90 - gather_facts 91 steps: 92 - name: Install architect 93 uses: giantswarm/install-binary-action@v1.0.0 94 with: 95 binary: "architect" 96 version: "6.1.0" 97 - name: Install semver 98 uses: giantswarm/install-binary-action@v1.0.0 99 with: 100 binary: "semver" 101 version: "3.2.0" 102 download_url: "https://github.com/fsaintjacques/${binary}-tool/archive/${version}.tar.gz" 103 tarball_binary_path: "*/src/${binary}" 104 smoke_test: "${binary} --version" 105 - name: Checkout code 106 uses: actions/checkout@v3 107 - name: Update project.go 108 id: update_project_go 109 env: 110 branch: "${{ github.ref }}-version-bump" 111 run: | 112 git checkout -b ${{ env.branch }} 113 file="${{ needs.gather_facts.outputs.project_go_path }}" 114 version="${{ needs.gather_facts.outputs.version }}" 115 new_version="$(semver bump patch $version)-dev" 116 echo "version=\"$version\" new_version=\"$new_version\"" 117 echo "::set-output name=new_version::${new_version}" 118 sed -Ei "s/(version[[:space:]]*=[[:space:]]*)\"${version}\"/\1\"${new_version}\"/" $file 119 if git diff --exit-code $file ; then 120 echo "error: no changes in \"$file\"" >&2 121 exit 1 122 fi 123 - name: Set up git identity 124 run: | 125 git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" 126 git config --local user.name "github-actions[bot]" 127 - name: Commit changes 128 run: | 129 file="${{ needs.gather_facts.outputs.project_go_path }}" 130 git add $file 131 git commit -m "Bump version to ${{ steps.update_project_go.outputs.new_version }}" 132 - name: Push changes 133 env: 134 REMOTE_REPO: "https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git" 135 branch: "${{ github.ref }}-version-bump" 136 run: | 137 git push "${REMOTE_REPO}" HEAD:${{ env.branch }} 138 - name: Create PR 139 env: 140 GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" 141 base: "${{ github.ref }}" 142 branch: "${{ github.ref }}-version-bump" 143 version: "${{ needs.gather_facts.outputs.version }}" 144 title: "Bump version to ${{ steps.update_project_go.outputs.new_version }}" 145 run: | 146 hub pull-request -f -m "${{ env.title }}" -b ${{ env.base }} -h ${{ env.branch }} -r ${{ github.actor }} 147 create_release: 148 name: Create release 149 runs-on: ubuntu-20.04 150 needs: 151 - gather_facts 152 if: ${{ needs.gather_facts.outputs.version }} 153 outputs: 154 upload_url: ${{ steps.create_gh_release.outputs.upload_url }} 155 steps: 156 - name: Checkout code 157 uses: actions/checkout@v3 158 with: 159 ref: ${{ github.sha }} 160 - name: Ensure correct version in project.go 161 if: ${{ needs.gather_facts.outputs.project_go_path != '' && needs.gather_facts.outputs.ref_version != 'true' }} 162 run: | 163 file="${{ needs.gather_facts.outputs.project_go_path }}" 164 version="${{ needs.gather_facts.outputs.version }}" 165 grep -qE "version[[:space:]]*=[[:space:]]*\"$version\"" $file 166 - name: Get Changelog Entry 167 id: changelog_reader 168 uses: mindsers/changelog-reader-action@v2 169 with: 170 version: ${{ needs.gather_facts.outputs.version }} 171 path: ./CHANGELOG.md 172 - name: Set up git identity 173 run: | 174 git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" 175 git config --local user.name "github-actions[bot]" 176 - name: Create tag 177 run: | 178 version="${{ needs.gather_facts.outputs.version }}" 179 git tag "v$version" ${{ github.sha }} 180 - name: Push tag 181 env: 182 REMOTE_REPO: "https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git" 183 run: | 184 git push "${REMOTE_REPO}" --tags 185 - name: Create release 186 id: create_gh_release 187 uses: actions/create-release@v1 188 env: 189 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 190 with: 191 body: ${{ steps.changelog_reader.outputs.changes }} 192 tag_name: "v${{ needs.gather_facts.outputs.version }}" 193 release_name: "v${{ needs.gather_facts.outputs.version }}" 194 195 create-release-branch: 196 name: Create release branch 197 runs-on: ubuntu-20.04 198 needs: 199 - gather_facts 200 if: ${{ needs.gather_facts.outputs.version }} 201 steps: 202 - name: Install semver 203 uses: giantswarm/install-binary-action@v1.0.0 204 with: 205 binary: "semver" 206 version: "3.0.0" 207 download_url: "https://github.com/fsaintjacques/${binary}-tool/archive/${version}.tar.gz" 208 tarball_binary_path: "*/src/${binary}" 209 smoke_test: "${binary} --version" 210 - name: Check out the repository 211 uses: actions/checkout@v3 212 with: 213 fetch-depth: 0 # Clone the whole history, not just the most recent commit. 214 - name: Fetch all tags and branches 215 run: "git fetch --all" 216 - name: Create long-lived release branch 217 run: | 218 current_version="${{ needs.gather_facts.outputs.version }}" 219 parent_version="$(git describe --tags --abbrev=0 HEAD^ || true)" 220 parent_version="${parent_version#v}" # Strip "v" prefix. 221 222 if [[ -z "$parent_version" ]] ; then 223 echo "Unable to find a parent tag version. No branch to create." 224 exit 0 225 fi 226 227 echo "current_version=$current_version parent_version=$parent_version" 228 229 current_major=$(semver get major $current_version) 230 current_minor=$(semver get minor $current_version) 231 parent_major=$(semver get major $parent_version) 232 parent_minor=$(semver get minor $parent_version) 233 echo "current_major=$current_major current_minor=$current_minor parent_major=$parent_major parent_minor=$parent_minor" 234 235 if [[ $current_major -gt $parent_major ]] ; then 236 echo "Current tag is a new major version" 237 elif [[ $current_major -eq $parent_major ]] && [[ $current_minor -gt $parent_minor ]] ; then 238 echo "Current tag is a new minor version" 239 else 240 echo "Current tag is not a new major or minor version. Nothing to do here." 241 exit 0 242 fi 243 244 release_branch="release-v${parent_major}.${parent_minor}.x" 245 echo "release_branch=$release_branch" 246 247 if git rev-parse --verify $release_branch ; then 248 echo "Release branch $release_branch already exists. Nothing to do here." 249 exit 0 250 fi 251 252 git branch $release_branch HEAD^ 253 git push origin $release_branch