Merge pull request #6 from tobenot/cursor/design-flexible-backend-pro… #23
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
| # .github/workflows/publish-contract.yml | |
| name: Publish API Contract to GitHub Packages | |
| on: | |
| push: | |
| paths: | |
| - 'src/**/*.ts' | |
| - 'dist/**/*.d.ts' | |
| - 'package.json' | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| packages: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| registry-url: 'https://npm.pkg.github.com' | |
| scope: '@tobenot' | |
| - name: Install dependencies | |
| run: npm ci | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Bump version if needed | |
| run: | | |
| latest=$(npm view @tobenot/basic-web-game-backend-contract version --registry=https://npm.pkg.github.com || echo "0.0.0") | |
| current=$(node -p "require('./package.json').version") | |
| if [ "$current" = "$latest" ]; then | |
| next=$(npx semver $latest -i patch) | |
| jq ".version = \"$next\"" package.json > package.json.tmp && mv package.json.tmp package.json | |
| echo "Bumped version to $next" | |
| else | |
| echo "No need to bump version" | |
| fi | |
| - name: Build | |
| run: npm run build | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Publish package | |
| run: npm publish --registry=https://npm.pkg.github.com | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |