Skip to content

Commit 5dd3976

Browse files
authored
ci: release (#248)
1 parent a6e5a12 commit 5dd3976

File tree

1 file changed

+159
-0
lines changed

1 file changed

+159
-0
lines changed

.github/workflows/release.yaml

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
#
2+
# Copyright (C) 2025 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+
on:
21+
workflow_dispatch:
22+
inputs:
23+
version:
24+
description: 'Version to release'
25+
required: true
26+
branch:
27+
description: 'Branch to use for the release'
28+
required: true
29+
default: main
30+
env:
31+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
32+
33+
jobs:
34+
35+
tag:
36+
name: Tagging
37+
runs-on: ubuntu-24.04
38+
outputs:
39+
githubTag: ${{ steps.TAG_UTIL.outputs.githubTag}}
40+
extVersion: ${{ steps.TAG_UTIL.outputs.extVersion}}
41+
releaseId: ${{ steps.create_release.outputs.id}}
42+
43+
steps:
44+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
45+
with:
46+
ref: ${{ github.event.inputs.branch }}
47+
- name: Generate tag utilities
48+
id: TAG_UTIL
49+
run: |
50+
TAG_PATTERN=${{ github.event.inputs.version }}
51+
echo "githubTag=v$TAG_PATTERN" >> ${GITHUB_OUTPUT}
52+
echo "extVersion=$TAG_PATTERN" >> ${GITHUB_OUTPUT}
53+
54+
- name: tag
55+
run: |
56+
git config --local user.name ${{ github.actor }}
57+
58+
# Add the new version in package.json file
59+
sed -i "s#version\":\ \"\(.*\)\",#version\":\ \"${{ steps.TAG_UTIL.outputs.extVersion }}\",#g" package.json
60+
sed -i "s#version\":\ \"\(.*\)\",#version\":\ \"${{ steps.TAG_UTIL.outputs.extVersion }}\",#g" packages/backend/package.json
61+
sed -i "s#version\":\ \"\(.*\)\",#version\":\ \"${{ steps.TAG_UTIL.outputs.extVersion }}\",#g" packages/frontend/package.json
62+
git add package.json
63+
git add packages/backend/package.json
64+
git add packages/frontend/package.json
65+
66+
# commit the changes
67+
git commit -m "chore: 🥁 tagging ${{ steps.TAG_UTIL.outputs.githubTag }} 🥳"
68+
echo "Tagging with ${{ steps.TAG_UTIL.outputs.githubTag }}"
69+
git tag ${{ steps.TAG_UTIL.outputs.githubTag }}
70+
git push origin ${{ steps.TAG_UTIL.outputs.githubTag }}
71+
- name: Create Release
72+
id: create_release
73+
uses: ncipollo/release-action@v1
74+
env:
75+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
76+
with:
77+
tag: ${{ steps.TAG_UTIL.outputs.githubTag }}
78+
name: ${{ steps.TAG_UTIL.outputs.githubTag }}
79+
draft: true
80+
prerelease: false
81+
82+
- name: Create the PR to bump the version in the main branch (only if we're tagging from main branch)
83+
if: ${{ github.event.inputs.branch == 'main' }}
84+
run: |
85+
git config --local user.name ${{ github.actor }}
86+
CURRENT_VERSION=$(echo "${{ steps.TAG_UTIL.outputs.extVersion }}")
87+
tmp=${CURRENT_VERSION%.*}
88+
minor=${tmp#*.}
89+
bumpedVersion=${CURRENT_VERSION%%.*}.$((minor + 1)).0
90+
bumpedBranchName="bump-to-${bumpedVersion}"
91+
git checkout -b "${bumpedBranchName}"
92+
sed -i "s#version\":\ \"\(.*\)\",#version\":\ \"${bumpedVersion}-next\",#g" package.json
93+
sed -i "s#version\":\ \"\(.*\)\",#version\":\ \"${bumpedVersion}-next\",#g" packages/backend/package.json
94+
sed -i "s#version\":\ \"\(.*\)\",#version\":\ \"${bumpedVersion}-next\",#g" packages/frontend/package.json
95+
git add package.json
96+
git add packages/backend/package.json
97+
git add packages/frontend/package.json
98+
git commit -s --amend -m "chore: bump version to ${bumpedVersion}"
99+
git push origin "${bumpedBranchName}"
100+
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
101+
pullRequestUrl=$(gh pr create --title "chore: 📢 Bump version to ${bumpedVersion}" --body-file /tmp/pr-title --head "${bumpedBranchName}" --base "main")
102+
echo "📢 Pull request created: ${pullRequestUrl}"
103+
echo "➡️ Flag the PR as being ready for review"
104+
gh pr ready "${pullRequestUrl}"
105+
echo "🔅 Mark the PR as being ok to be merged automatically"
106+
gh pr merge "${pullRequestUrl}" --auto --rebase
107+
git checkout ${{ steps.TAG_UTIL.outputs.githubTag }}
108+
env:
109+
GITHUB_TOKEN: ${{ secrets.PODMAN_DESKTOP_BOT_TOKEN }}
110+
111+
build:
112+
needs: [tag]
113+
runs-on: ubuntu-24.04
114+
steps:
115+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
116+
with:
117+
ref: ${{ needs.tag.outputs.githubTag }}
118+
119+
- uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0
120+
name: Install pnpm
121+
with:
122+
run_install: false
123+
124+
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
125+
with:
126+
node-version: 22
127+
cache: 'pnpm'
128+
129+
- name: Execute yarn
130+
run: pnpm install
131+
132+
- name: Run Build
133+
run: pnpm build
134+
135+
- name: Login to ghcr.io
136+
run: podman login --username ${{ github.repository_owner }} --password ${{ secrets.GITHUB_TOKEN }} ghcr.io
137+
138+
- name: Build Image
139+
id: build-image
140+
run: |
141+
podman build -t ghcr.io/${{ github.repository_owner }}/podman-desktop-extension-postgresql:${{ needs.tag.outputs.extVersion }} .
142+
podman push ghcr.io/${{ github.repository_owner }}/podman-desktop-extension-postgresql:${{ needs.tag.outputs.extVersion }}
143+
podman tag ghcr.io/${{ github.repository_owner }}/podman-desktop-extension-postgresql:${{ needs.tag.outputs.extVersion }} ghcr.io/${{ github.repository_owner }}/podman-desktop-extension-postgresql:latest
144+
podman push ghcr.io/${{ github.repository_owner }}/podman-desktop-extension-postgresql:latest
145+
146+
release:
147+
needs: [tag, build]
148+
name: Release
149+
runs-on: ubuntu-24.04
150+
steps:
151+
- name: id
152+
run: echo the release id is ${{ needs.tag.outputs.releaseId}}
153+
154+
- name: Publish release
155+
uses: StuYarrow/[email protected]
156+
env:
157+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
158+
with:
159+
id: ${{ needs.tag.outputs.releaseId}}

0 commit comments

Comments
 (0)