Skip to content

Commit

Permalink
feat(version): Create a pull request for the release process (#195)
Browse files Browse the repository at this point in the history
This workflow consists in 2 steps:

1. The create-pre-release-pr.yaml workflow that triggers a lerna-lite version command
   and creates a pull request with the changes

2. Once the pull request is done, the release-and-publish.yml workflow publish the
   changed packages by using the lerna-lite publish from-package command and later on
   it creates a release. The latter is not working due to lack of permissions to create
   the release.
  • Loading branch information
lordrip authored Oct 5, 2023
1 parent 41d7dff commit b80b77e
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: 🏷️ Trigger Version and publish npm Package
name: ↗️ Create a Pull request for a new release
# Event for the workflow
on:
workflow_dispatch:
Expand All @@ -8,12 +8,12 @@ concurrency:
group: "publish"
cancel-in-progress: true

jobs:
trigger-version-and-publish:
if: github.repository == 'KaotoIO/kaoto-next' && github.actor != 'renovate[bot]'

jobs:
create-pre-release-pr:
permissions:
contents: write
pull-requests: write

runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -50,9 +50,23 @@ jobs:
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
# Version and publish
- name: "Version and publish"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.KAOTO_NEXT_NPM_TOKEN }}
run: yarn publish
- name: Version
run: yarn version

- name: Get version
id: get_version
run: |
echo "TITLE=$(git --no-pager log --format=%s -n 1)" >> $GITHUB_OUTPUT
# echo "BODY='$(git --no-pager log --format=%B -n 1)'" >> $GITHUB_OUTPUT

- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
with:
commit-message: "chore: release"
title: ${{ steps.get_version.outputs.TITLE }}
body: ${{ steps.get_version.outputs.BODY }}
branch: chore/pre-release
base: main
token: ${{ secrets.GITHUB_TOKEN }}
delete-branch: true
labels: release
55 changes: 55 additions & 0 deletions .github/workflows/release-and-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: 🏷️ Release and publish a new version of the package
on:
# Run on pull request merged from a `pre-release` branch into the `main` branch\
pull_request:
types:
- closed
branches:
- main
paths:
- 'packages/**/CHANGELOG.md'

jobs:
release-and-publish:
permissions:
contents: write

if: github.event.pull_request.merged == true

runs-on: ubuntu-latest
steps:
- name: 'Checkout source code'
uses: actions/checkout@v4

- uses: actions/setup-node@v3
with:
node-version: '18.x'
registry-url: 'https://registry.npmjs.org'
scope: '@kaoto-next'
cache: 'yarn'

- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'

- name: 🔧 Install dependencies
run: yarn

# Build lib
- name: Build @kaoto-next/ui package in lib mode
run: yarn workspace @kaoto-next/ui run build:lib

# Version and publish
- name: 'Version and publish'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.KAOTO_NEXT_NPM_TOKEN }}
run: yarn publish

- name: Create Release
uses: ncipollo/[email protected]
with:
draft: true
commit: ${{ github.event.pull_request.head.sha }}
tag: ${{ github.event.pull_request.head.ref }}
14 changes: 8 additions & 6 deletions lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@
"conventionalCommits": true,
"changelog": true,
"message": "chore(release): publish",
"createRelease": "github",
"loglevel": "debug",
"command": {
"version": {
"tag": false,
"push": false,
"yes": true
},
"publish": {
"tag": true,
"push": true,
"pushArgs": [
"--follow-tags"
],
"tag": false,
"push": false,
"yes": true
}
}
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
},
"scripts": {
"postinstall": "yarn workspace @kaoto-next/camel-catalog run build",
"publish": "lerna publish"
"version": "lerna version",
"publish": "lerna publish from-package"
},
"engines": {
"node": "18.x"
Expand Down

0 comments on commit b80b77e

Please sign in to comment.