diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0d9704cab..41da6acea 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,9 +1,11 @@ -name: Build +name: Build and Publish Httpsnippet on: push: branches: - master + tags: + - '*' # Restrict any specific tag formats pull_request: types: - opened @@ -11,6 +13,26 @@ on: workflow_dispatch: jobs: + scan: + permissions: + packages: write + contents: write # publish sbom to GH releases/tag assets + runs-on: ubuntu-latest + steps: + - name: Checkout branch + uses: actions/checkout@v3 + with: + path: ${{ github.repository }} + + # Perform SCA analysis for the code repository + # Produces SBOM and CVE report + # Helps understand vulnerabilities / license compliance across third party dependencies + - id: sca-project + uses: Kong/public-shared-actions/security-actions/sca@2f02738ecb1670f01391162e43fe3f5d4e7942a1 # v2.2.2 + with: + dir: ${{ github.repository }} + upload-sbom-release-assets: true + build: runs-on: ubuntu-latest strategy: @@ -37,3 +59,31 @@ jobs: - name: Build run: npm run build + + publish: + runs-on: ubuntu-latest + if: ${{ github.ref_type == 'tag' && github.repository_owner == 'Kong' }} + steps: + # checkout tag + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 20.9.0 + registry-url: 'https://registry.npmjs.org' + + - name: Install + run: npm ci + + - name: Build + run: npm run build + + - name: Publish to NPM + run: npm publish --no-git-checks --provenance --tag ${{ github.sha }} + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + diff --git a/.github/workflows/publish.yml b/.github/workflows/release.yml similarity index 68% rename from .github/workflows/publish.yml rename to .github/workflows/release.yml index cfbfb8bc7..1a9045479 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,4 @@ -name: Publish httpsnippet +name: Release httpsnippet on: workflow_dispatch: @@ -8,7 +8,7 @@ on: required: true jobs: - publish: + release: runs-on: ubuntu-latest steps: - name: Checkout code @@ -16,12 +16,6 @@ jobs: with: fetch-depth: 0 - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version: 20.9.0 - registry-url: 'https://registry.npmjs.org' - - name: Configure Git user uses: Homebrew/actions/git-user-config@master with: @@ -42,15 +36,4 @@ jobs: prerelease: false draft: false env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Install - run: npm ci - - - name: Build - run: npm run build - - - name: Publish to NPM - run: npm publish - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file