|
| 1 | +# |
| 2 | +# Copyright (C) 2024-2026 Red Hat, Inc. |
| 3 | +# |
| 4 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +# you may not use this file except in compliance with the License. |
| 6 | +# You may obtain a copy of the License at |
| 7 | +# |
| 8 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +# |
| 10 | +# Unless required by applicable law or agreed to in writing, software |
| 11 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +# See the License for the specific language governing permissions and |
| 14 | +# limitations under the License. |
| 15 | +# |
| 16 | +# SPDX-License-Identifier: Apache-2.0 |
| 17 | + |
| 18 | +name: release |
| 19 | + |
| 20 | +permissions: |
| 21 | + contents: read |
| 22 | + |
| 23 | +on: |
| 24 | + workflow_dispatch: |
| 25 | + inputs: |
| 26 | + version: |
| 27 | + description: 'Version to release' |
| 28 | + required: true |
| 29 | + branch: |
| 30 | + description: 'Branch to use for the release' |
| 31 | + required: true |
| 32 | + default: main |
| 33 | +env: |
| 34 | + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} |
| 35 | + |
| 36 | +jobs: |
| 37 | + tag: |
| 38 | + name: Tagging |
| 39 | + runs-on: ubuntu-24.04 |
| 40 | + permissions: |
| 41 | + contents: write |
| 42 | + pull-requests: write |
| 43 | + outputs: |
| 44 | + githubTag: ${{ steps.TAG_UTIL.outputs.githubTag}} |
| 45 | + extVersion: ${{ steps.TAG_UTIL.outputs.extVersion}} |
| 46 | + releaseId: ${{ steps.create_release.outputs.id}} |
| 47 | + |
| 48 | + steps: |
| 49 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 50 | + with: |
| 51 | + ref: ${{ github.event.inputs.branch }} |
| 52 | + - name: Generate tag utilities |
| 53 | + id: TAG_UTIL |
| 54 | + run: | |
| 55 | + TAG_PATTERN=${{ github.event.inputs.version }} |
| 56 | + echo "githubTag=v$TAG_PATTERN" >> ${GITHUB_OUTPUT} |
| 57 | + echo "extVersion=$TAG_PATTERN" >> ${GITHUB_OUTPUT} |
| 58 | +
|
| 59 | + - name: tag |
| 60 | + run: | |
| 61 | + git config --local user.name ${{ github.actor }} |
| 62 | +
|
| 63 | + # Add the new version in package.json file |
| 64 | + sed -i "s#version\":\ \"\(.*\)\",#version\":\ \"${{ steps.TAG_UTIL.outputs.extVersion }}\",#g" package.json |
| 65 | + sed -i "s#version\":\ \"\(.*\)\",#version\":\ \"${{ steps.TAG_UTIL.outputs.extVersion }}\",#g" packages/backend/package.json |
| 66 | + sed -i "s#version\":\ \"\(.*\)\",#version\":\ \"${{ steps.TAG_UTIL.outputs.extVersion }}\",#g" packages/frontend/package.json |
| 67 | + sed -i "s#version\":\ \"\(.*\)\",#version\":\ \"${{ steps.TAG_UTIL.outputs.extVersion }}\",#g" packages/shared/package.json |
| 68 | + git add package.json |
| 69 | + git add packages/backend/package.json |
| 70 | + git add packages/frontend/package.json |
| 71 | + git add packages/shared/package.json |
| 72 | +
|
| 73 | + # commit the changes |
| 74 | + git commit -m "chore: 🥁 tagging ${{ steps.TAG_UTIL.outputs.githubTag }} 🥳" |
| 75 | + echo "Tagging with ${{ steps.TAG_UTIL.outputs.githubTag }}" |
| 76 | + git tag ${{ steps.TAG_UTIL.outputs.githubTag }} |
| 77 | + git push origin ${{ steps.TAG_UTIL.outputs.githubTag }} |
| 78 | +
|
| 79 | + - name: Create Release |
| 80 | + id: create_release |
| 81 | + uses: ncipollo/release-action@339a81892b84b4eeb0f6e744e4574d79d0d9b8dd # v1.21.0 |
| 82 | + env: |
| 83 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 84 | + with: |
| 85 | + tag: ${{ steps.TAG_UTIL.outputs.githubTag }} |
| 86 | + name: ${{ steps.TAG_UTIL.outputs.githubTag }} |
| 87 | + draft: true |
| 88 | + prerelease: false |
| 89 | + |
| 90 | + # - name: Create the PR to bump the version in the main branch (only if we're tagging from main branch) |
| 91 | + # if: ${{ github.event.inputs.branch == 'main' }} |
| 92 | + # run: | |
| 93 | + # git config --local user.name ${{ github.actor }} |
| 94 | + # CURRENT_VERSION=$(echo "${{ steps.TAG_UTIL.outputs.extVersion }}") |
| 95 | + # tmp=${CURRENT_VERSION%.*} |
| 96 | + # minor=${tmp#*.} |
| 97 | + # bumpedVersion=${CURRENT_VERSION%%.*}.$((minor + 1)).0 |
| 98 | + # bumpedBranchName="bump-to-${bumpedVersion}" |
| 99 | + # git checkout -b "${bumpedBranchName}" |
| 100 | + # sed -i "s#version\":\ \"\(.*\)\",#version\":\ \"${bumpedVersion}-next\",#g" package.json |
| 101 | + # sed -i "s#version\":\ \"\(.*\)\",#version\":\ \"${bumpedVersion}-next\",#g" packages/backend/package.json |
| 102 | + # sed -i "s#version\":\ \"\(.*\)\",#version\":\ \"${bumpedVersion}-next\",#g" packages/frontend/package.json |
| 103 | + # sed -i "s#version\":\ \"\(.*\)\",#version\":\ \"${bumpedVersion}-next\",#g" packages/shared/package.json |
| 104 | + # git add package.json |
| 105 | + # git add packages/backend/package.json |
| 106 | + # git add packages/frontend/package.json |
| 107 | + # git add packages/shared/package.json |
| 108 | + # git commit -s --amend -m "chore: bump version to ${bumpedVersion}" |
| 109 | + # git push origin "${bumpedBranchName}" |
| 110 | + # echo -e "📢 Bump version to ${bumpedVersion}\n\n${{ steps.TAG_UTIL.outputs.extVersion }} has been released.\n\n Time to switch to the new ${bumpedVersion} version 🥳" > /tmp/pr-title |
| 111 | + # pullRequestUrl=$(gh pr create --title "chore: 📢 Bump version to ${bumpedVersion}" --body-file /tmp/pr-title --head "${bumpedBranchName}" --base "main") |
| 112 | + # echo "📢 Pull request created: ${pullRequestUrl}" |
| 113 | + # echo "➡️ Flag the PR as being ready for review" |
| 114 | + # gh pr ready "${pullRequestUrl}" |
| 115 | + # echo "🔅 Mark the PR as being ok to be merged automatically" |
| 116 | + # gh pr merge "${pullRequestUrl}" --auto --rebase |
| 117 | + # git checkout ${{ steps.TAG_UTIL.outputs.githubTag }} |
| 118 | + # env: |
| 119 | + # GITHUB_TOKEN: ${{ secrets.PODMAN_DESKTOP_BOT_TOKEN }} |
| 120 | + |
| 121 | + build-oci: |
| 122 | + needs: [tag] |
| 123 | + runs-on: ubuntu-24.04 |
| 124 | + permissions: |
| 125 | + contents: read |
| 126 | + outputs: |
| 127 | + artifact-id: ${{ steps.build.outputs.artifact-id }} |
| 128 | + steps: |
| 129 | + - uses: podman-desktop/gh-extensions-actions/.github/actions/oci-build@19efb8f2422c54ad8904ad068ad363bcabaacc96 # v0.1.0 |
| 130 | + name: build-oci |
| 131 | + with: |
| 132 | + image-name: '${{ github.repository }}' |
| 133 | + ref: ${{ needs.tag.outputs.githubTag }} |
| 134 | + |
| 135 | + publish-oci: |
| 136 | + needs: [build-oci] |
| 137 | + runs-on: ubuntu-24.04 |
| 138 | + permissions: |
| 139 | + contents: read |
| 140 | + packages: write |
| 141 | + steps: |
| 142 | + - uses: podman-desktop/gh-extensions-actions/.github/actions/oci-publish@19efb8f2422c54ad8904ad068ad363bcabaacc96 # v0.1.0 |
| 143 | + name: publish-oci |
| 144 | + with: |
| 145 | + image-name: '${{ github.repository }}' |
| 146 | + registry: 'ghcr.io' |
| 147 | + registry-username: ${{ github.repository_owner }} |
| 148 | + registry-password: ${{ secrets.GITHUB_TOKEN }} |
| 149 | + tag: ${{ needs.tag.outputs.extVersion }} latest |
| 150 | + artifact-id: ${{ needs.build-oci.outputs.artifact-id }} |
| 151 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 152 | + |
| 153 | + release: |
| 154 | + needs: [tag, publish-oci] |
| 155 | + name: Release |
| 156 | + runs-on: ubuntu-24.04 |
| 157 | + permissions: |
| 158 | + contents: write |
| 159 | + steps: |
| 160 | + - name: id |
| 161 | + run: echo the release id is ${{ needs.tag.outputs.releaseId}} |
| 162 | + |
| 163 | + - name: Publish release |
| 164 | + uses: StuYarrow/publish-release@01f2a1365bacd77bad861873a7fdf274ab49eefd # v1.1.2 |
| 165 | + env: |
| 166 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 167 | + with: |
| 168 | + id: ${{ needs.tag.outputs.releaseId}} |
0 commit comments