Skip to content

Make some small refactoring related to variables #156

Make some small refactoring related to variables

Make some small refactoring related to variables #156

name: Publish to GPR & Publish Github Release
on:
pull_request:
branches:
- develop
types: [ closed ]
jobs:
publish-gpr:
if: ${{ github.event.pull_request.merged == true && startsWith(github.head_ref, 'release/')}}
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
registry-url: https://npm.pkg.github.com/
- run: |
npm ci
npm test
npm run build:esm
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
publish-github-release:
needs: publish-gpr
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
issues: write
steps:
- id: publish-linked-draft-release
name: Publish linked draft release
env:
GH_TOKEN: ${{ github.token }}
PR_ID: ${{ github.event.pull_request.number }}
PR_LABELS: ${{ join(github.event.pull_request.labels.*.name, ', ') }}
run: |
# find the github release id from labels
RELEASE_ID=$(echo $PR_LABELS | sed 's/.*RID_\([^,]*\).*/\1/')
# publish the github release
gh api \
--method PATCH \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/$GITHUB_REPOSITORY/releases/$RELEASE_ID \
-f target_commitish="develop" \
-F draft=false \
-F prerelease=false \
-F make_latest=true > release.json
# update PR description
cat release.json | jq -r .body > body.md
echo -e "\n\nPublished release: $(cat release.json | jq -r .html_url)" >> body.md
echo -e "\nTo install: \`npm i --save-exact @secretkeylabs/xverse-core@$(cat release.json | jq -r .tag_name | sed 's/v//')\`" >> body.md
gh api \
--method PATCH \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/$GITHUB_REPOSITORY/pulls/$PR_ID \
-F '[email protected]'