Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Publish to GitHub Packages | |
| on: | |
| release: | |
| types: [published] | |
| jobs: | |
| publish-gpr: | |
| name: GitHub Packages publish | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set Scope Name | |
| run: | | |
| sed -i 's/"name": "topluyo-bot"/"name": "@topluyo\/topluyo-bot"/' package.json | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18' | |
| registry-url: 'https://npm.pkg.github.com' | |
| scope: '@${{ github.repository_owner }}' | |
| - name: Install dependencies | |
| run: npm install | |
| - name: Check if version already exists on GitHub Packages | |
| id: version_check | |
| run: | | |
| PKG=$(node -p "require('./package.json').name") | |
| VER=$(node -p "require('./package.json').version") | |
| if npm view "${PKG}@${VER}" --registry https://npm.pkg.github.com/ >/dev/null 2>&1; then | |
| echo "skip=true" >> "$GITHUB_OUTPUT" | |
| echo "Version ${VER} already exists on GitHub Packages — skipping publish." | |
| else | |
| echo "skip=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Publish package | |
| if: steps.version_check.outputs.skip != 'true' | |
| run: npm publish --access public | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |