Skip to content

Commit

Permalink
chore: add cut-release and publish gh-actions
Browse files Browse the repository at this point in the history
  • Loading branch information
rnons committed Jun 6, 2024
1 parent 40f372e commit 28ef3ab
Show file tree
Hide file tree
Showing 8 changed files with 5,294 additions and 2,288 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/cut-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Cut Release

on:
workflow_dispatch:
inputs:
commit:
description: 'Commit to be cut to final released, default to head'
required: false
default: ""
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
ref: ${{ github.event.inputs.commit }}
token: ${{ secrets.ACCESS_TOKEN }}
- name: Sync Release Branch
run: |
git remote set-url origin https://${{ secrets.ACCESS_TOKEN }}@github.com/sentioxyz/sentio-sdk
git checkout -b release
git log -1
git push -f --set-upstream origin release
71 changes: 71 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Publish to npm

on:
push:
branches:
- main
- release
- v1
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
ref: ${{ github.event.inputs.commit }}
- uses: pnpm/action-setup@v4
with:
version: 9
- uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'
registry-url: 'https://registry.npmjs.org'
- name: Set NPM variables
id: npm
run: |
BRANCH=${GITHUB_REF##*/}
DIST_TAG=rc
if [[ $BRANCH == "release" ]]; then
DIST_TAG=latest
fi
echo "dist_tag=${DIST_TAG}" >> $GITHUB_OUTPUT
pnpm config list
- name: Install
run: pnpm install
- name: Semantic Release
id: semantic
uses: cycjimmy/semantic-release-action@v4
with:
semantic_version: 23.1.1
env:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
- name: Release Summary
if: steps.semantic.outputs.new_release_published == 'true'
run: |
echo "### New version v${{ steps.semantic.outputs.new_release_version }} cut" >> $GITHUB_STEP_SUMMARY
echo "commit: ${GITHUB_SHA}, branch/tag: ${GITHUB_REF}" >> $GITHUB_STEP_SUMMARY
echo "${{ steps.semantic.outputs.new_release_notes }}" >> $GITHUB_STEP_SUMMARY
env:
GH_TOKEN: ${{ secrets.ACCESS_TOKEN }}
- name: NPM Publish
if: steps.semantic.outputs.new_release_published == 'true'
run: |
./scripts/update-version.sh ${{ steps.semantic.outputs.new_release_version }}
pnpm publish --no-git-checks --tag ${{ steps.npm.outputs.dist_tag }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: report error
if: steps.semantic.outputs.new_release_published == 'false'
run: |
echo "### No version cut" >> $GITHUB_STEP_SUMMARY
echo "Check Semantic Release output for details"
- name: Clean Github Release for RC
if: ${{ contains(steps.semantic.outputs.new_release_version, '-rc.') == false }}
run: ./scripts/clean-rc-releases.sh
env:
GH_TOKEN: ${{ secrets.ACCESS_TOKEN }}
18 changes: 13 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,27 @@
"type": "git",
"url": "https://github.com/sentioxyz/api.git"
},
"main": "./dist/index.js",
"typings": "./dist/index.d.ts",
"module": "./dist/esm/index.js",
"type": "module",
"exports": {
".": "./dist/src/index.js"
},
"files": [
"{dist,src}",
"!dist/test",
"!**/.openapi-generator*"
],
"sideEffects": false,
"scripts": {
"build": "tsc && tsc -p tsconfig.json",
"build": "tsc",
"test": "jest",
"prepare": "yarn build"
"prepare": "pnpm build"
},
"devDependencies": {
"@types/jest": "^29.5.12",
"@types/node": "^20.14.1",
"jest": "^29.4.1",
"json": "^11.0.0",
"semantic-release": "^24.0.0",
"ts-jest": "^29.0.5",
"ts-node": "^10.9.1",
"tslib": "^2.6.3",
Expand Down
Loading

0 comments on commit 28ef3ab

Please sign in to comment.