Skip to content

Commit

Permalink
feat: automate homebrew-tap
Browse files Browse the repository at this point in the history
  • Loading branch information
omidasadpour committed Jan 15, 2024
1 parent 6c1585a commit 4e4ec8d
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 1 deletion.
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
name: Node CI Suite
on: push
on:
push:
workflow_call:
jobs:
test:
runs-on: macos-latest
Expand Down
68 changes: 68 additions & 0 deletions .github/workflows/npm-package-updater.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Update NPM Package

on:
workflow_dispatch:
repository_dispatch:
types:
- update-package

jobs:
update-package:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 14

- name: Git configuration
run: |
git config --global user.email "bot@sunodo"
git config --global user.name "GitHub Actions release workflow"
- name: Install dependencies
run: npm install

- name: Get latest package information
id: get-package
run: |
PACKAGE_NAME="@sunodo/cli"
PACKAGE_VERSION=$(npm show $PACKAGE_NAME version)
PACKAGE_URL=$(npm show $PACKAGE_NAME dist.tarball)
npm pack @sunodo/cli@$PACKAGE_VERSION
PACKAGE_SHA256=$(sha256sum sunodo-cli-$PACKAGE_VERSION.tgz | awk '{print $1}')
if [ -z "$PACKAGE_VERSION" ] || [ -z "$PACKAGE_URL" ] || [ -z "$PACKAGE_SHA256" ]; then
echo "Failed to retrieve package information. Exiting..."
exit 1
fi
echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV
echo "PACKAGE_URL=$PACKAGE_URL" >> $GITHUB_ENV
echo "PACKAGE_SHA256=$PACKAGE_SHA256" >> $GITHUB_ENV
- name: Update formula file
run: |
sed -i.bak -e "s|url \".*\"|url \"$PACKAGE_URL\"|" Formula/sunodo.rb
sed -i.bak -e "s|sha256 \".*\"|sha256 \"$PACKAGE_SHA256\"|" Formula/sunodo.rb
- name: Commit CHANGELOG.md and package.json changes and create tag
run: |
git add Formula/sunodo.rb
git commit -m "chore: update NPM package to version ${{ env.PACKAGE_VERSION }}"
# Push changes to origin
- name: Push changes to repository
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git push origin
suite:
name: suite
needs: update-package
uses: ./.github/workflows/ci.yml

0 comments on commit 4e4ec8d

Please sign in to comment.