Skip to content

Dispatch release

Dispatch release #3

name: Dispatch release
on:
workflow_dispatch:
inputs:
release-version:
description: Release version (X.X)
required: true
type: string
jobs:
dispatch-release:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout aggregator repository
uses: actions/checkout@v4
with:
submodules: false
ref: release-workflow
- uses: actions/create-github-app-token@21cfef2b496dd8ef5b904c159339626a10ad380e # v1 v1.11.6
id: app-token
name: Generate app token
with:
app-id: ${{ vars.GRIDSUITE_ACTIONS_APPID }}
private-key: ${{ secrets.VERSIONBUMP_GHAPP_PRIVATE_KEY }}
owner: gridsuite
- name: Get GitHub App User ID
id: get-user-id
run: |
echo $(gh api "/users/${RUNGHA_APP_SLUG}[bot]")
echo "user-id=$(gh api "/users/${RUNGHA_APP_SLUG}[bot]" --jq .id)" >> "$GITHUB_OUTPUT"
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
RUNGHA_APP_SLUG: ${{ steps.app-token.outputs.app-slug }} # just for defense against script injection
- name: Setup git user
run: |
git config --global user.name "${RUNGHA_APP_SLUG}[bot]"
git config --global user.email "${RUNGHA_USER_ID}+${RUNGHA_APP_SLUG}[bot]@users.noreply.github.com"
env:
RUNGHA_APP_SLUG: ${{ steps.app-token.outputs.app-slug }} # just for defense against script injection
RUNGHA_USER_ID: ${{ steps.get-user-id.outputs.user-id }} # just for defense against script injection
- name: Load repo list from file or input
id: load_repos
run: |
if [[ -z "${{ github.event.inputs.repos_to_release }}" ]]; then
echo "ℹ️ No user input → load .github/config/repos-to-release.txt"
list="$(cat .github/config/repos-to-release.txt)"
else
echo "ℹ️ Input found → load user input"
list="${{ github.event.inputs.repos_to_release }}"
fi
echo "list<<EOF" >> $GITHUB_OUTPUT
echo "$list" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Create tags and trigger release workflows
run: |
while read url; do
url_with_token="${url/https:\/\/github.com/https:\/\/x-access-token:${GH_TOKEN}@github.com}"
git clone "$url_with_token"
folder=$(basename "$url" .git)
cd $folder
version=${{github.event.inputs.release-version}}
branch_name="prepare-release-$version"
# Check if *branch_name* already exists
if ! git ls-remote --exit-code origin "refs/heads/$branch_name"; then
echo "❌ Warning for $folder: Branch $branch_name does not exist"
exit 1
fi
git checkout "$branch_name"
tag_name="v$version"
# Créer le tag
git tag "$tag_name"
# Pousser le tag
git push origin "$tag_name"
gh api repos/gridsuite/$folder/actions/workflows/release.yml/dispatches \
-f ref=main \
-f inputs.releaseVersion="v${{ github.event.inputs.release-version }}"
cd -
done <<< "${{ steps.load_repos.outputs.list }}"
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}