name: CI on: pull_request: push: branches: - master - "feature/*" tags: - "v*" jobs: build: name: Build and Test runs-on: ${{ matrix.os }} strategy: matrix: os: [ubuntu-latest, windows-latest] steps: - name: Checkout uses: actions/checkout@v4 with: fetch-depth: 0 - name: Setup Node.js uses: actions/setup-node@v4 with: node-version: "20" cache: "npm" - name: Install dependencies run: npm ci - name: Build run: npm run build - name: Format check run: npm run format-check - name: Lint run: npm run lint - name: Test run: npm test - name: Package run: npm run package - name: Run Action uses: ./ id: run with: debug: true - name: Print version run: echo "Version ${{ steps.run.outputs.version }}" env: DEBUG_OUTPUT: ${{ steps.run.outputs.debug_output }} release: name: Publish Release needs: build if: startsWith(github.ref, 'refs/tags/v') runs-on: ubuntu-latest environment: release permissions: contents: write id-token: write steps: - name: Checkout uses: actions/checkout@v4 with: fetch-depth: 0 - name: Setup Node.js uses: actions/setup-node@v4 with: node-version: "20" cache: "npm" registry-url: "https://registry.npmjs.org" - name: Install dependencies run: npm ci - name: Build run: npm run build - name: Package run: npm run package - name: Extract version from tag id: tag run: | VERSION=${GITHUB_REF#refs/tags/v} echo "version=$VERSION" >> $GITHUB_OUTPUT echo "major=$(echo $VERSION | cut -d. -f1)" >> $GITHUB_OUTPUT - name: Update package.json version run: npm version ${{ steps.tag.outputs.version }} --no-git-tag-version - name: Publish to npm run: npm publish --provenance --access public env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - name: Update major version tag run: | git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" git tag -fa v${{ steps.tag.outputs.major }} -m "Update v${{ steps.tag.outputs.major }} to ${{ steps.tag.outputs.version }}" git push origin v${{ steps.tag.outputs.major }} --force - name: Create GitHub Release uses: softprops/action-gh-release@v2 with: generate_release_notes: true body: | ## Installation ### GitHub Action ```yaml - uses: paulhatch/semantic-version@v${{ steps.tag.outputs.major }} ``` ### CLI ```bash npm install -g @semanticversion/cli ```