Skip to content

Commit

Permalink
Introduce new release flow - Part 2 (segmentio#2150)
Browse files Browse the repository at this point in the history
* Introduce new release flow

* quick check to validate push permissios

* revert changes

* revert release.sh

* Revert unwanted changes

* Restore gh pat token change

* run file count check after add

* Add unique_id

* more updates to workflow

* fix fetch-depth

* use multiline string

* Another fix for multiline output

* directly use step output
  • Loading branch information
varadarajan-tw authored Jul 9, 2024
1 parent eb87b6f commit 74ed708
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions .github/workflows/version-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ jobs:
steps:
- uses: actions/checkout@v4
with:
ref: main
depth: 0
fetch-depth: 0

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
Expand Down Expand Up @@ -51,22 +50,26 @@ jobs:
- name: Commit and push
id: commit_and_push
run: |
git add .
count=$(git diff --cached --stat)
if [ -z "$count" ]; then
echo "No changes to commit"
echo "SKIP_PR=true" >> $GITHUB_OUTPUT
exit 0
fi
git add .
git commit -m "chore: version packages"
packages_published=$(git status -s -uno| grep "package.json" |awk '{print $2}'| xargs jq -r '.name + "@" + .version' --argjson null {})
echo "packages_published<<EOF" >> $GITHUB_OUTPUT
echo "$packages_published" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
git commit -m "version packages"
git push origin ${{ github.event.inputs.branch }}
- name: Create PR
if: ${{ steps.commit_and_push.outputs.SKIP_PR != 'true' }}
run: |
packages_published=$(git status -s -uno| grep "package.json" |awk '{print $2}'| xargs jq -r '.name + "@" + .version' --argjson null {})
pr_message="This PR was opened by GithHub Actions. Whenever you're ready to publish the packages, merge this PR."
description="$(printf "%s\n # Packages\n%s" "$pr_message" "$packages_published")"
description="$(printf "%s\n # Packages\n%s" "$pr_message" "${{ steps.commit_and_push.outputs.packages_published }}")"
gh pr create --base main --head ${{ github.event.inputs.branch }} --title "Publish" --body "$description"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 74ed708

Please sign in to comment.