mirror of
https://github.com/twentyhq/twenty.git
synced 2024-09-11 23:37:21 +03:00
Fix/release workflow (#5802)
Here is a fix for https://github.com/twentyhq/twenty/issues/5163 I tested it on another repo and should work as intended this time arround. I've created two workflows - One that creates a PR - The second that watch PR merge with specific labels - I also check the author of the PR to make sure it was created by a bot You can now disable the creation of the a draft release --------- Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
parent
4a7a8c72ef
commit
2fdd2f4949
44
.github/workflows/ci-release-create.yaml
vendored
Normal file
44
.github/workflows/ci-release-create.yaml
vendored
Normal file
@ -0,0 +1,44 @@
|
||||
name: "Release: create"
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
version:
|
||||
required: true
|
||||
description: Version to release, without the v (e.g. 1.2.3)
|
||||
ref:
|
||||
default: main
|
||||
description: Ref to start the release from (e.g. main, sha)
|
||||
create_release:
|
||||
type: boolean
|
||||
default: true
|
||||
description: Create a release after merging the PR
|
||||
|
||||
jobs:
|
||||
create_pr:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
ref: ${{ github.event.inputs.ref }}
|
||||
|
||||
- name: Sanitize version
|
||||
id: sanitize
|
||||
run: |
|
||||
echo version=$(echo ${{ github.event.inputs.version }} | sed 's/^v//') >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Update versions
|
||||
run: |
|
||||
echo ${{ steps.sanitize.outputs.version }} > version.txt
|
||||
|
||||
- name: Create Pull Request
|
||||
uses: peter-evans/create-pull-request@v6
|
||||
with:
|
||||
branch: release/${{ steps.sanitize.outputs.version }}
|
||||
commit-message: "chore: release v${{ steps.sanitize.outputs.version }}"
|
||||
committer: Github Action Deploy <github-action-deploy@twenty.com>
|
||||
author: Github Action Deploy <github-action-deploy@twenty.com>
|
||||
title: Release v${{ steps.sanitize.outputs.version }}
|
||||
labels: |
|
||||
release
|
||||
${{ github.event.inputs.create_release == true && 'create_release' || '' }}
|
47
.github/workflows/ci-release-merge.yaml
vendored
Normal file
47
.github/workflows/ci-release-merge.yaml
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
name: "Release: on merge"
|
||||
on:
|
||||
pull_request:
|
||||
types:
|
||||
- closed
|
||||
|
||||
jobs:
|
||||
tag_and_release:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'release')
|
||||
steps:
|
||||
- name: Check PR Author
|
||||
id: check_author
|
||||
run: |
|
||||
if [[ "${{ github.event.pull_request.user.login }}" != "github-actions[bot]" ]]; then
|
||||
echo "PR author (${AUTHOR}) is not trusted. Exiting."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
ref: main
|
||||
|
||||
- name: Get version from PR title
|
||||
id: extract_version
|
||||
run: |
|
||||
VERSION=$(echo "${{ github.event.pull_request.title }}" | sed -n 's/.*Release v\([0-9.]*\).*/\1/p')
|
||||
if [ -z "$VERSION" ]; then
|
||||
echo "No valid version found in PR title. Exiting."
|
||||
exit 1
|
||||
fi
|
||||
echo "VERSION=$VERSION" >> $GITHUB_ENV
|
||||
|
||||
- name: Push new tag
|
||||
run: |
|
||||
git config --global user.name 'Github Action Deploy'
|
||||
git config --global user.email 'github-action-deploy@twenty.com'
|
||||
git tag v${{ env.VERSION }}
|
||||
git push origin v${{ env.VERSION }}
|
||||
|
||||
- uses: release-drafter/release-drafter@v5
|
||||
if: contains(github.event.pull_request.labels.*.name, 'create_release')
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
tag: v${{ env.VERSION }}
|
52
.github/workflows/ci-release.yaml
vendored
52
.github/workflows/ci-release.yaml
vendored
@ -1,52 +0,0 @@
|
||||
name: Release Twenty
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
version:
|
||||
required: true
|
||||
description: Version to release, without the v (e.g. 1.2.3)
|
||||
ref:
|
||||
default: main
|
||||
description: Ref to start the release from (e.g. main, sha)
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
ref: ${{ github.event.inputs.ref }}
|
||||
|
||||
- name: Sanitize version
|
||||
id: sanitize
|
||||
run: |
|
||||
echo version=$(echo ${{ github.event.inputs.version }} | sed 's/^v//') >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Update versions
|
||||
working-directory: packages
|
||||
run: |
|
||||
for dir in twenty-emails twenty-front twenty-server twenty-ui twenty-website
|
||||
do
|
||||
cd $dir
|
||||
yarn version ${{ steps.sanitize.outputs.version }}
|
||||
cd ..
|
||||
done
|
||||
|
||||
# Make sure we have the latest changes before committing
|
||||
- name: Pull changes
|
||||
run: git pull
|
||||
|
||||
- uses: stefanzweifel/git-auto-commit-action@v4
|
||||
with:
|
||||
branch: ${{ github.event.inputs.ref }}
|
||||
commit_message: "chore: release v${{ steps.sanitize.outputs.version }}"
|
||||
tagging_message: v${{ steps.sanitize.outputs.version }}
|
||||
|
||||
commit_user_name: Github Action Deploy
|
||||
commit_user_email: github-action-deploy@twenty.com
|
||||
commit_author: Github Action Deploy <github-action-deploy@twenty.com>
|
||||
|
||||
- uses: release-drafter/release-drafter@v5
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
Loading…
Reference in New Issue
Block a user