Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ on:
description: 'Update pre-release into latest.'
type: boolean
default: true
delete-rc-branch:
description: 'Delete rc* branch at the end of process.'
type: boolean
default: true

permissions:
contents: read
Expand All @@ -25,13 +21,14 @@ jobs:
permissions:
id-token: write
contents: write
pull-requests: write
#uses: OutSystems/ui-components.github-reusable-workflows/.github/workflows/release.yaml@7ffd7f90f6e5016bd92d0e050d2516084b99c2f6 #v0.2.5
uses: ./.github/workflows/template-release.yaml
with:
new-version: ${{ inputs.new-version }}
update-prerelease-into-latest: ${{ inputs.update-prerelease-into-latest }}
delete-rc-branch: ${{ inputs.delete-rc-branch }}
secrets:
OSUI_AZURE_CLIENT_ID: ${{ secrets.OSUI_AZURE_CLIENT_ID }}
OSUI_AZURE_TENANT_ID: ${{ secrets.OSUI_AZURE_TENANT_ID }}
OSUI_AZURE_SUBSCRIPTION_ID: ${{ secrets.OSUI_AZURE_SUBSCRIPTION_ID }}
OSUI_AZURE_SUBSCRIPTION_ID: ${{ secrets.OSUI_AZURE_SUBSCRIPTION_ID }}
OSUI_SLACK_WEBHOOK_URL: ${{ secrets.OSUI_SLACK_WEBHOOK_URL }}
82 changes: 52 additions & 30 deletions .github/workflows/template-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
# with:
# new-version: ${{ inputs.new-version }}
# update-prerelease-into-latest: true
# delete-rc-branch: true
# secrets:
# OSUI_SLACK_WEBHOOK_URL: ${{ secrets.OSUI_SLACK_WEBHOOK_URL }} # Slack incoming webhook used to notify the channel when the release PR is created
#
# ======================================================================
#
Expand All @@ -36,10 +37,6 @@ on:
description: 'Update pre-release into latest.'
type: boolean
default: true
delete-rc-branch:
description: 'Delete rc* branch at the end of process.'
type: boolean
default: true
secrets:
OSUI_AZURE_CLIENT_ID:
description: 'Azure Client ID for authentication'
Expand All @@ -50,6 +47,9 @@ on:
OSUI_AZURE_SUBSCRIPTION_ID:
description: 'Azure Subscription ID for authentication'
required: true
OSUI_SLACK_WEBHOOK_URL:
description: 'Slack incoming webhook URL for release notifications'
required: true

jobs:
run-lint-on-rc:
Expand Down Expand Up @@ -83,6 +83,7 @@ jobs:
permissions:
id-token: write
contents: read
pull-requests: write

if: ${{ inputs.new-version }}
steps:
Expand All @@ -104,13 +105,53 @@ jobs:
with:
key-name: o11odc-github-gitpersonal-token-prd

- name: 🔄 Merge rc${{ inputs.new-version }} into main
uses: everlytic/branch-merge@c4a244dc23143f824ae6c022a10732566cb8e973 #v1.1.5
- name: 🔄 Create release PR for rc${{ inputs.new-version }} into main
id: create-release-pr
env:
GH_TOKEN: ${{ steps.get-github-token.outputs.az-keyvault-value }}
run: |
SOURCE_BRANCH="rc${{ inputs.new-version }}"
BASE_BRANCH="main"
PR_TITLE="Merge ${SOURCE_BRANCH} into ${BASE_BRANCH} [skip ci]"

COMPARE_STATUS=$(gh api \
"repos/${{ github.repository }}/compare/${BASE_BRANCH}...${SOURCE_BRANCH}" \
--template '{{.status}}')

if [ "${COMPARE_STATUS}" = "identical" ] || [ "${COMPARE_STATUS}" = "behind" ]; then
echo "${SOURCE_BRANCH} is already merged into ${BASE_BRANCH}."
exit 0
fi

PR_NUMBER=$(gh pr list \
--head "${SOURCE_BRANCH}" \
--base "${BASE_BRANCH}" \
--state open \
--limit 1 \
--json number \
--jq '.[0].number // empty')

if [ -z "${PR_NUMBER}" ]; then
PR_URL=$(gh pr create \
--base "${BASE_BRANCH}" \
--head "${SOURCE_BRANCH}" \
--title "${PR_TITLE}" \
--body "$(printf 'This PR merges %s into %s.\n\nThis PR was automatically created by the Release workflow.\n' "${SOURCE_BRANCH}" "${BASE_BRANCH}")")
echo "Release PR: ${PR_URL}"
echo "pr-created=true" >> "$GITHUB_OUTPUT"
echo "pr-url=${PR_URL}" >> "$GITHUB_OUTPUT"
else
echo "Release PR: https://github.com/${{ github.repository }}/pull/${PR_NUMBER}"
fi

- name: 📢 Notify Slack about release PR
if: steps.create-release-pr.outputs.pr-created == 'true'
uses: slackapi/slack-github-action@91efab103c0de0a537f72a35f6b8cda0ee76bf0a # v2.1.1
with:
github_token: ${{ steps.get-github-token.outputs.az-keyvault-value }}
source_ref: rc${{ inputs.new-version }}
target_branch: 'main'
commit_message_template: 'Merged rc${{ inputs.new-version }} into main. [skip ci]'
webhook: ${{ secrets.OSUI_SLACK_WEBHOOK_URL }}
webhook-type: incoming-webhook
payload: |
text: "A release PR was created and is waiting to be merged! Please take the required actions. ${{ steps.create-release-pr.outputs.pr-url }}"

set-pre-release-as-lts:
name: Set pre-release as LTS
Expand Down Expand Up @@ -147,22 +188,3 @@ jobs:
prerelease: false
token: ${{ steps.get-github-token.outputs.az-keyvault-value }}
make_latest: true

delete-rc-branch:
name: Delete rc branch
needs: merge-rc-into-main
runs-on: ubuntu-latest
permissions:
contents: write

if: ${{ inputs.delete-rc-branch == true }}
steps:
- name: 📥 Checkout branch dev
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
ref: dev

- name: 🗑️ Delete branch rc${{ inputs.new-version }}
shell: bash
run: |
git push origin -d rc${{ inputs.new-version }}
Loading