sync staking stake ixs #159
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish to NPM Registry | |
on: | |
# When Release Pull Request is merged | |
pull_request: | |
branches: | |
- master | |
- v6 | |
- v7 | |
types: [closed] | |
permissions: | |
contents: write # for checkout and tag | |
pull-requests: write # for comments | |
packages: write # for publish | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: pnpm/action-setup@v4 | |
with: | |
version: 9 | |
- name: Use Node.js 20 | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: "pnpm" | |
registry-url: https://registry.npmjs.org/ | |
- name: Install dependencies | |
run: pnpm install | |
- name: Git Identity | |
run: | | |
git config --global user.name 'github-actions[bot]' | |
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | |
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/$GITHUB_REPOSITORY | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Validate NPM Token | |
run: | | |
echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" > .npmrc | |
npm whoami | |
if [ $? -ne 0 ]; then | |
echo "::error::NPM token validation failed. Please check your NPM_PUBLISH_TOKEN secret." | |
exit 1 | |
fi | |
echo "NPM token validated successfully." | |
rm -f .npmrc | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} | |
- name: Set Current Version | |
run: | | |
CURRENT_VERSION=$(node -p 'require("./lerna.json").version') | |
echo "CURRENT_VERSION=${CURRENT_VERSION}" >> $GITHUB_ENV | |
- name: Tag Check | |
id: tag_check | |
run: | | |
GET_API_URL="https://api.github.com/repos/${GITHUB_REPOSITORY}/git/ref/tags/v${CURRENT_VERSION}" | |
http_status_code=$(curl -LI $GET_API_URL -o /dev/null -w '%{http_code}\n' -s \ | |
-H "Authorization: token ${GITHUB_TOKEN}") | |
if [ "$http_status_code" -ne "404" ] ; then | |
echo "::set-output name=exists_tag::true" | |
else | |
echo "::set-output name=exists_tag::false" | |
fi | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Publish | |
if: steps.tag_check.outputs.exists_tag == 'false' | |
run: | | |
npm run publish | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} | |
- name: Create Git Tag | |
if: steps.tag_check.outputs.exists_tag == 'false' | |
uses: pkgdeps/git-tag-action@v2 | |
with: | |
version: ${{ env.CURRENT_VERSION }} | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
github_repo: ${{ github.repository }} | |
git_commit_sha: ${{ github.sha }} | |
git_tag_prefix: "v" | |
- name: Create Release | |
id: create_release | |
if: steps.tag_check.outputs.exists_tag == 'false' && github.event.pull_request.merged == true | |
uses: softprops/action-gh-release@v1 | |
with: | |
tag_name: v${{ env.CURRENT_VERSION }} | |
name: v${{ env.CURRENT_VERSION }} | |
body: | | |
${{ github.event.pull_request.body }} | |
draft: false | |
prerelease: false | |
- uses: actions/github-script@v4 | |
with: | |
github-token: ${{secrets.GITHUB_TOKEN}} | |
script: | | |
github.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: 'https://github.com/${{ github.repository }}/releases/tag/v${{ env.CURRENT_VERSION }} is released 🎉' | |
}) |