mirror of
https://github.com/Dokploy/cli.git
synced 2026-06-15 20:25:22 +02:00
- Replaced the usage of secrets.GH_TOKEN with github.token in onPushToMain.yml for improved security and access management during the release process.
61 lines
1.7 KiB
YAML
61 lines
1.7 KiB
YAML
name: release and publish
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
|
|
env:
|
|
COREPACK_ENABLE_STRICT: 0
|
|
|
|
jobs:
|
|
release:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: pnpm/action-setup@v6
|
|
with:
|
|
version: latest
|
|
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: latest
|
|
cache: pnpm
|
|
registry-url: https://registry.npmjs.org
|
|
|
|
- run: pnpm install --ignore-scripts
|
|
- run: pnpm run build
|
|
|
|
- name: Check if version already exists
|
|
id: version-check
|
|
run: |
|
|
package_version=$(node -p "require('./package.json').version")
|
|
exists=$(gh api repos/${{ github.repository }}/releases/tags/v$package_version >/dev/null 2>&1 && echo "true" || echo "")
|
|
|
|
if [ -n "$exists" ]; then
|
|
echo "Version v$package_version already exists"
|
|
echo "skipped=true" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "Version v$package_version does not exist"
|
|
echo "skipped=false" >> $GITHUB_OUTPUT
|
|
echo "tag=v$package_version" >> $GITHUB_OUTPUT
|
|
fi
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
|
|
- name: Create Github Release
|
|
if: steps.version-check.outputs.skipped == 'false'
|
|
uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5
|
|
with:
|
|
name: ${{ steps.version-check.outputs.tag }}
|
|
tag: ${{ steps.version-check.outputs.tag }}
|
|
commit: ${{ github.ref_name }}
|
|
token: ${{ github.token }}
|
|
skipIfReleaseExists: true
|
|
|
|
- name: Publish to npm
|
|
if: steps.version-check.outputs.skipped == 'false'
|
|
run: pnpm publish --no-git-checks
|
|
env:
|
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|