56 lines
1.7 KiB
YAML
56 lines
1.7 KiB
YAML
name: Publish npm package
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'v*'
|
|
|
|
jobs:
|
|
publish:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '20'
|
|
|
|
- name: Set version from tag
|
|
run: |
|
|
VERSION=${GITHUB_REF_NAME#v}
|
|
echo "Setting package version to $VERSION"
|
|
npm pkg set version="$VERSION"
|
|
SHA=$(curl -s -H "Authorization: token ${GITEA_TOKEN}" \
|
|
"https://git.blassanto.me/api/v1/repos/blas/openapi-clean-arch-gen/contents/package.json?ref=main" \
|
|
| node -e "let d='';process.stdin.on('data',c=>d+=c).on('end',()=>console.log(JSON.parse(d).sha))")
|
|
CONTENT=$(base64 -w 0 package.json)
|
|
curl -s -X PUT \
|
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
|
-H "Content-Type: application/json" \
|
|
"https://git.blassanto.me/api/v1/repos/blas/openapi-clean-arch-gen/contents/package.json" \
|
|
-d "{\"message\":\"chore: bump to version v${VERSION}\",\"content\":\"${CONTENT}\",\"sha\":\"${SHA}\",\"branch\":\"main\"}"
|
|
env:
|
|
GITEA_TOKEN: ${{ secrets.TOKEN }}
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Lint
|
|
run: npm run lint
|
|
|
|
- name: Build
|
|
run: npm run build
|
|
|
|
- name: Configure Gitea registry auth
|
|
run: |
|
|
echo "//git.blassanto.me/api/packages/blas/npm/:_authToken=${NODE_AUTH_TOKEN}" >> ~/.npmrc
|
|
env:
|
|
NODE_AUTH_TOKEN: ${{ secrets.PUBLISH_TOKEN }}
|
|
|
|
- name: Publish to Gitea
|
|
run: npm publish
|
|
env:
|
|
NODE_AUTH_TOKEN: ${{ secrets.PUBLISH_TOKEN }}
|