Skip to content

Commit ee11110

Browse files
author
LE SAULNIER Kevin
committed
feat: add dispatch release workflow
Signed-off-by: LE SAULNIER Kevin <[email protected]>
1 parent 2a09ac9 commit ee11110

File tree

2 files changed

+97
-1
lines changed

2 files changed

+97
-1
lines changed
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
release-version:
7+
description: Release version (X.X)
8+
required: true
9+
type: string
10+
11+
jobs:
12+
dispatch-release:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: read
16+
17+
steps:
18+
- name: Checkout aggregator repository
19+
uses: actions/checkout@v4
20+
with:
21+
submodules: false
22+
ref: release-workflow
23+
24+
- uses: actions/create-github-app-token@21cfef2b496dd8ef5b904c159339626a10ad380e # v1 v1.11.6
25+
id: app-token
26+
name: Generate app token
27+
with:
28+
app-id: ${{ vars.GRIDSUITE_ACTIONS_APPID }}
29+
private-key: ${{ secrets.VERSIONBUMP_GHAPP_PRIVATE_KEY }}
30+
owner: gridsuite
31+
32+
- name: Get GitHub App User ID
33+
id: get-user-id
34+
run: |
35+
echo $(gh api "/users/${RUNGHA_APP_SLUG}[bot]")
36+
echo "user-id=$(gh api "/users/${RUNGHA_APP_SLUG}[bot]" --jq .id)" >> "$GITHUB_OUTPUT"
37+
env:
38+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
39+
RUNGHA_APP_SLUG: ${{ steps.app-token.outputs.app-slug }} # just for defense against script injection
40+
41+
- name: Setup git user
42+
run: |
43+
git config --global user.name "${RUNGHA_APP_SLUG}[bot]"
44+
git config --global user.email "${RUNGHA_USER_ID}+${RUNGHA_APP_SLUG}[bot]@users.noreply.github.com"
45+
env:
46+
RUNGHA_APP_SLUG: ${{ steps.app-token.outputs.app-slug }} # just for defense against script injection
47+
RUNGHA_USER_ID: ${{ steps.get-user-id.outputs.user-id }} # just for defense against script injection
48+
49+
- name: Load repo list from file or input
50+
id: load_repos
51+
run: |
52+
if [[ -z "${{ github.event.inputs.repos_to_release }}" ]]; then
53+
echo "ℹ️ No user input → load .github/config/repos-to-release.txt"
54+
list="$(cat .github/config/repos-to-release.txt)"
55+
else
56+
echo "ℹ️ Input found → load user input"
57+
list="${{ github.event.inputs.repos_to_release }}"
58+
fi
59+
echo "list<<EOF" >> $GITHUB_OUTPUT
60+
echo "$list" >> $GITHUB_OUTPUT
61+
echo "EOF" >> $GITHUB_OUTPUT
62+
63+
- name: Create tags and trigger release workflows
64+
run: |
65+
while read url; do
66+
url_with_token="${url/https:\/\/github.com/https:\/\/x-access-token:${GH_TOKEN}@github.com}"
67+
git clone "$url_with_token"
68+
folder=$(basename "$url" .git)
69+
cd $folder
70+
71+
version=${{github.event.inputs.release-version}}
72+
branch_name="prepare-release-$version"
73+
# Check if *branch_name* already exists
74+
if ! git ls-remote --exit-code origin "refs/heads/$branch_name"; then
75+
echo "❌ Warning for $folder: Branch $branch_name does not exist"
76+
exit 1
77+
fi
78+
git checkout "$branch_name"
79+
80+
tag_name="v$version"
81+
# Créer le tag
82+
git tag "$tag_name"
83+
84+
# Pousser le tag
85+
git push origin "$tag_name"
86+
87+
gh api repos/gridsuite/$folder/actions/workflows/release.yml/dispatches \
88+
-f ref=main \
89+
-f inputs.releaseVersion="v${{ github.event.inputs.release-version }}"
90+
91+
cd -
92+
done <<< "${{ steps.load_repos.outputs.list }}"
93+
env:
94+
GH_TOKEN: ${{ steps.app-token.outputs.token }}

.github/workflows/prepare-release.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010
description: "Date of last commit to inlude (ISO 8601, ex: 2024-09-13T23:59:59Z - default : last friday 23:59:59)."
1111
required: false
1212
release-version:
13-
description: "Version for new tag (ex: v2.8.0)"
13+
description: "Version for new tag (ex: 2.8)"
1414
required: true
1515
secrets:
1616
VERSIONBUMP_GHAPP_PRIVATE_KEY:
@@ -94,11 +94,13 @@ jobs:
9494
# Check if *branch_name* already exists
9595
if git ls-remote --exit-code origin "refs/heads/$branch_name"; then
9696
echo "❌ Warning for $folder: Branch $branch_name already exists"
97+
exit 1
9798
fi
9899
git checkout -b "$branch_name"
99100
100101
if ! git push origin "$branch_name"; then
101102
echo "❌ Error for $folder: Failed to push $branch_name"
103+
exit 1
102104
fi
103105
104106
commit_message=$(git log -1 --pretty=%s | cut -c1-50)

0 commit comments

Comments
 (0)