Skip to content

Commit

Permalink
chore: change workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
BO-LIKE-CHICKEN committed Jul 15, 2024
1 parent 5f2014f commit 7b73bc8
Showing 1 changed file with 28 additions and 20 deletions.
48 changes: 28 additions & 20 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,33 +18,41 @@ jobs:
with:
node-version: "20"

- name: Install jq
run: sudo apt-get install -y jq

- name: Install pnpm
- name: Install dependencies
run: |
npm install -g pnpm
pnpm config set store-dir ~/.pnpm-store
pnpm install
- name: Cache pnpm store
uses: actions/cache@v3
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install
- name: Install gh CLI
run: sudo apt-get install -y gh

- name: Update version in package.json
if: github.ref_type == 'branch'
- name: Authenticate gh CLI
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
jq --arg build "$GITHUB_RUN_NUMBER" --arg commit "${GITHUB_SHA::8}" \
'.version = .version + "-dev." + $build + "+" + $commit' package.json > package.json.tmp
mv package.json.tmp package.json
echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token
- name: Release
- name: Run semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: pnpm run release

- name: Check for changes
id: git_diff
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions"
git checkout -b release-branch
git add CHANGELOG.md package.json
if [ -n "$(git status --porcelain)" ]; then
git commit -m "chore(release): Create release PR"
echo "true" > has_changes.txt
else
echo "false" > has_changes.txt
fi
- name: Create Pull Request
if: steps.git_diff.outputs.has_changes == 'true'
run: |
gh pr create --title "Release PR" --body "This PR includes changes for the new release." --head release-branch --base main

0 comments on commit 7b73bc8

Please sign in to comment.