Skip to content

Commit

Permalink
feat: Add publish CI
Browse files Browse the repository at this point in the history
  • Loading branch information
extg5 committed Aug 19, 2024
1 parent 23e28e9 commit 4b753db
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 1 deletion.
61 changes: 61 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Publish

on:
push:
branches:
- main

jobs:
publish:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
registry-url: 'https://registry.npmjs.org'

- name: Check if version has changed
id: version_check
run: |
# Get the current version from package.json
current_version=$(jq -r '.version' package.json)
echo "Current version: $current_version"
# Get the previous version from the last commit
git fetch --depth=2
previous_version=$(git show HEAD^1:package.json | jq -r '.version')
echo "Previous version: $previous_version"
if [ "$current_version" != "$previous_version" ]; then
echo "::set-output name=version_changed::true"
echo "::set-output name=current_version::$current_version"
else
echo "::set-output name=version_changed::false"
fi
- name: Publish to NPM
if: steps.version_check.outputs.version_changed == 'true'
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_CI_TOKEN }}
run: |
yarn
yarn build
npm publish
- name: Create GitHub Release
if: steps.version_check.outputs.version_changed == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
current_version=${{ steps.version_check.outputs.current_version }}
gh release create "v$current_version" \
--title "Release v$current_version" \
--generate-notes
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,6 @@
"aptos": "^1.3.17",
"axios": "^0.27.2",
"decimal.js": "^10.4.1"
}
},
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
}

1 comment on commit 4b753db

@dabloo-wstf
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this is not working on the latest version of the aptos . will it work with updated version of aptos or I should search for the another alternative dex.

Please sign in to comment.