Update Buildpack and Run Image Versions #9
This file contains hidden or 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
| name: Update Buildpack and Run Image Versions | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: New release version (e.g. 0.46.0) | |
| type: string | |
| required: true | |
| pull_request: | |
| types: [closed] | |
| jobs: | |
| validate-tag: | |
| if: github.event_name == 'workflow_dispatch' | |
| runs-on: ubuntu-latest | |
| outputs: | |
| repo_lower: ${{ steps.lowercase_repo.outputs.REPO }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Check if tag exists | |
| run: | | |
| if git tag -l | grep -q "^${{ github.event.inputs.version }}$"; then | |
| echo "Error: Tag ${{ github.event.inputs.version }} already exists" | |
| exit 1 | |
| else | |
| echo "Tag ${{ github.event.inputs.version }} does not exist - proceeding" | |
| fi | |
| - name: lowercase REPO | |
| id: lowercase_repo | |
| run: | | |
| echo "REPO=${GITHUB_REPOSITORY@L}" >> "${GITHUB_OUTPUT}" | |
| build-and-push-run-image: | |
| if: github.event_name == 'workflow_dispatch' | |
| runs-on: ubuntu-latest | |
| needs: validate-tag | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| with: | |
| driver: docker-container | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push run-image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: ./run-image | |
| file: ./run-image/Dockerfile | |
| push: true | |
| tags: ghcr.io/${{ needs.validate-tag.outputs.repo_lower }}/base-image:${{ github.event.inputs.version }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| create-version-update-pr: | |
| if: github.event_name == 'workflow_dispatch' | |
| runs-on: ubuntu-latest | |
| needs: [validate-tag, build-and-push-run-image] | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Update buildpack.toml versions | |
| run: make update-buildpack-versions RELEASE_VERSION=${{ github.event.inputs.version }} | |
| - name: Update builder.toml | |
| run: make update-builder-versions RELEASE_VERSION=${{ github.event.inputs.version }} | |
| - name: Create Pull Request | |
| uses: peter-evans/create-pull-request@v7 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| commit-message: "chore(release): Update buildpack and run-image versions to ${{ github.event.inputs.version }}" | |
| title: "chore(release): Update versions to ${{ github.event.inputs.version }}" | |
| body: | | |
| Automated version update for release ${{ github.event.inputs.version }} | |
| - Updated buildpack.toml versions | |
| - Updated builder.toml versions | |
| This PR was created automatically by the release workflow. | |
| **Please review and merge to complete the release process.** | |
| branch: update-versions-${{ github.event.inputs.version }} | |
| base: main | |
| delete-branch: true | |
| - name: Trigger tests | |
| uses: peter-evans/repository-dispatch@v3 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| event-type: run-tests-for-release-pr | |
| client-payload: | | |
| { | |
| "branch": "update-versions-${{ github.event.inputs.version }}" | |
| } | |
| release: | |
| if: github.event_name == 'pull_request' && github.event.pull_request.merged == true && startsWith(github.head_ref, 'update-versions-') | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| packages: write | |
| steps: | |
| - name: Extract version from branch name | |
| id: extract_version | |
| run: | | |
| VERSION=${GITHUB_HEAD_REF#update-versions-} | |
| echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT" | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Move tag to merged commit | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git tag -f ${{ steps.extract_version.outputs.VERSION }} | |
| git push origin ${{ steps.extract_version.outputs.VERSION }} --force --tags | |
| - name: publish buildpacks | |
| run: make publish_buildpacks | |
| - name: publish builders | |
| run: make publish_builders | |
| - name: Create Release | |
| uses: ncipollo/release-action@v1 | |
| with: | |
| tag: ${{ steps.extract_version.outputs.VERSION }} | |
| name: Release ${{ steps.extract_version.outputs.VERSION }} | |
| generateReleaseNotes: true | |
| draft: false | |
| prerelease: false | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Cleanup branch | |
| run: | | |
| git push origin --delete update-versions-${{ steps.extract_version.outputs.VERSION }} |