feat: add Gitea Actions workflow for publishing to npm
This commit is contained in:
parent
d2f70086ad
commit
877fb62064
46
.gitea/workflows.publishToNpm.yaml
Normal file
46
.gitea/workflows.publishToNpm.yaml
Normal file
|
@ -0,0 +1,46 @@
|
|||
name: Publish to npm
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- dev
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: '22'
|
||||
registry-url: 'https://registry.npmjs.org/'
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm install
|
||||
|
||||
- name: Determine package name
|
||||
id: package_name
|
||||
run: |
|
||||
if [ "${{ gitea.ref }}" == "refs/heads/main" ]; then
|
||||
echo "PACKAGE_NAME=datenel-react" >> $GITEA_ENV
|
||||
echo "ACCESS_LEVEL=public" >> $GITEA_ENV
|
||||
elif [ "${{ gitea.ref }}" == "refs/heads/dev" ]; then
|
||||
echo "PACKAGE_NAME=@astrian/datenel-vue3-dev" >> $GITEA_ENV
|
||||
echo "ACCESS_LEVEL=restricted" >> $GITEA_ENV
|
||||
fi
|
||||
|
||||
- name: Update package.json for dev releases
|
||||
if: GITEA.ref == 'refs/heads/dev'
|
||||
run: |
|
||||
jq --arg name "@astrian/datenel-vue3-dev" '.name=$name' package.json > temp.json && mv temp.json package.json
|
||||
jq --arg version "0.0.0-dev.$(date +%s)" '.version=$version' package.json > temp.json && mv temp.json package.json
|
||||
|
||||
- name: Publish to npm
|
||||
run: npm publish --access $ACCESS_LEVEL
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
Loading…
Reference in New Issue
Block a user