Skip to content

Commit

Permalink
refactor(config): update release workflows for vis and ana to use pul…
Browse files Browse the repository at this point in the history
…l request triggers
  • Loading branch information
IhsenBouallegue committed Dec 12, 2024
1 parent 5c80e71 commit ef1a002
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 39 deletions.
45 changes: 14 additions & 31 deletions .github/workflows/prepare-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,11 @@ on:
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
new_version: ${{ steps.version.outputs.new_version }}
prefix: ${{ steps.version.outputs.prefix }}
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/checkout@v4
with:
fetch-depth: 0

Expand All @@ -47,35 +43,22 @@ jobs:
echo "new_version=${NEW_VERSION}" >> $GITHUB_OUTPUT
echo "prefix=${{ inputs.repository == 'Visualization' && 'vis' || 'ana' }}" >> $GITHUB_OUTPUT
- name: Create release branch and commit changes
run: |
# Create a new branch
git checkout -b release/${{ steps.version.outputs.prefix }}-${{ steps.version.outputs.new_version }}
# Stage and commit changes
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add -A
git commit -m "Releasing ${{ steps.version.outputs.prefix }}-${{ steps.version.outputs.new_version }} [skip ci]"
# Create tag (will be pushed with the merge)
git tag "${{ steps.version.outputs.prefix }}-${{ steps.version.outputs.new_version }}"
# Push branch
git push origin release/${{ steps.version.outputs.prefix }}-${{ steps.version.outputs.new_version }}
- name: Create release pull request
uses: peter-evans/create-pull-request@v5
- name: Create Pull Request
id: cpr
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "Releasing ${{ steps.version.outputs.prefix }}-${{ steps.version.outputs.new_version }} [skip ci]"
committer: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
author: ${{ github.actor }} <${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com>
branch: release/${{ steps.version.outputs.prefix }}-${{ steps.version.outputs.new_version }}
delete-branch: true
title: "Release ${{ inputs.repository }} ${{ steps.version.outputs.new_version }}"
body: |
Automated PR for releasing ${{ inputs.repository }} version ${{ steps.version.outputs.new_version }}
This PR was automatically created by the release workflow.
After merging, the tag `${{ steps.version.outputs.prefix }}-${{ steps.version.outputs.new_version }}` will trigger the release workflow.
branch: release/${{ steps.version.outputs.prefix }}-${{ steps.version.outputs.new_version }}
base: main
labels: release
delete-branch: true

# The appropriate release workflow will be triggered after the PR is merged
After merging, the release workflow will create a tag `${{ steps.version.outputs.prefix }}-${{ steps.version.outputs.new_version }}` and start the release process.
labels: |
release
draft: false
16 changes: 12 additions & 4 deletions .github/workflows/release-analysis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
name: Release - Analysis

on:
push:
tags: 'ana-*.*.*'
pull_request:
types:
- closed
branches:
- 'release/ana-*'


env:
VERSION: "0.0.0"

jobs:
promote_and_release:
if: |
github.event.pull_request.merged == true &&
contains(github.event.pull_request.labels.*.name, 'release')
name: Promote and Release
runs-on: ubuntu-latest
permissions:
Expand All @@ -19,10 +26,11 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

# Extract version from tag
# Extract version from branch name
- name: Set version
run: |
echo "VERSION=${GITHUB_REF#refs/tags/ana-}" >> $GITHUB_ENV
BRANCH_NAME="${{ github.event.pull_request.head.ref }}"
echo "VERSION=${BRANCH_NAME#release/ana-}" >> $GITHUB_ENV
# Build just for release artifacts
- name: Setup Node.js
Expand Down
23 changes: 19 additions & 4 deletions .github/workflows/release-visualization.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
name: Release - Visualization

on:
push:
tags: 'vis-*.*.*'
pull_request:
types:
- closed
branches:
- 'release/vis-*'

env:
VERSION: "0.0.0"

jobs:
promote_and_release:
if: |
github.event.pull_request.merged == true &&
contains(github.event.pull_request.labels.*.name, 'release')
name: Promote and Release
runs-on: ubuntu-latest
permissions:
Expand All @@ -19,10 +25,19 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

# Extract version from tag
# Extract version from branch name
- name: Set version
run: |
echo "VERSION=${GITHUB_REF#refs/tags/vis-}" >> $GITHUB_ENV
BRANCH_NAME="${{ github.event.pull_request.head.ref }}"
echo "VERSION=${BRANCH_NAME#release/vis-}" >> $GITHUB_ENV
# Create and push tag
- name: Create tag
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git tag "vis-${{ env.VERSION }}"
git push origin "vis-${{ env.VERSION }}"
# Build just for release artifacts
- name: Setup Node.js
Expand Down

0 comments on commit ef1a002

Please sign in to comment.