Skip to content

Commit 2e8c285

Browse files
chore(feat/slsa)[SEC-1085]: add publish pipeline [INS-3792] (#347)
* chore: add publish pipeline [INS-3792] * refactor build and publish pipeline to add provenance and sbom scan --------- Co-authored-by: saisatishkarra <[email protected]>
1 parent 7efd8e0 commit 2e8c285

File tree

2 files changed

+94
-1
lines changed

2 files changed

+94
-1
lines changed

.github/workflows/build.yml

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,38 @@
1-
name: Build
1+
name: Build and Publish Httpsnippet
22

33
on:
44
push:
55
branches:
66
- master
7+
tags:
8+
- '*' # Restrict any specific tag formats
79
pull_request:
810
types:
911
- opened
1012
- synchronize
1113
workflow_dispatch:
1214

1315
jobs:
16+
scan:
17+
permissions:
18+
packages: write
19+
contents: write # publish sbom to GH releases/tag assets
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Checkout branch
23+
uses: actions/checkout@v3
24+
with:
25+
path: ${{ github.repository }}
26+
27+
# Perform SCA analysis for the code repository
28+
# Produces SBOM and CVE report
29+
# Helps understand vulnerabilities / license compliance across third party dependencies
30+
- id: sca-project
31+
uses: Kong/public-shared-actions/security-actions/sca@2f02738ecb1670f01391162e43fe3f5d4e7942a1 # v2.2.2
32+
with:
33+
dir: ${{ github.repository }}
34+
upload-sbom-release-assets: true
35+
1436
build:
1537
runs-on: ubuntu-latest
1638
strategy:
@@ -37,3 +59,31 @@ jobs:
3759

3860
- name: Build
3961
run: npm run build
62+
63+
publish:
64+
runs-on: ubuntu-latest
65+
if: ${{ github.ref_type == 'tag' && github.repository_owner == 'Kong' }}
66+
steps:
67+
# checkout tag
68+
- name: Checkout code
69+
uses: actions/checkout@v4
70+
with:
71+
fetch-depth: 0
72+
73+
- name: Setup Node.js
74+
uses: actions/setup-node@v4
75+
with:
76+
node-version: 20.9.0
77+
registry-url: 'https://registry.npmjs.org'
78+
79+
- name: Install
80+
run: npm ci
81+
82+
- name: Build
83+
run: npm run build
84+
85+
- name: Publish to NPM
86+
run: npm publish --no-git-checks --provenance --tag ${{ github.sha }}
87+
env:
88+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
89+

.github/workflows/release.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Release httpsnippet
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Tag version to release'
8+
required: true
9+
10+
env:
11+
# Release Tag to build and publish
12+
TAG: ${{ github.event.inputs.version }}
13+
14+
jobs:
15+
release:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
23+
- name: Configure Git user
24+
uses: Homebrew/actions/git-user-config@master
25+
with:
26+
username: ${{ (github.event_name == 'workflow_dispatch' && github.actor) || 'insomnia-infra' }}
27+
28+
- name: Tag the Repository
29+
run: |
30+
git tag ${{ env.TAG }}
31+
git push origin ${{ env.TAG }}
32+
33+
- name: Create Tag and Release
34+
uses: ncipollo/release-action@v1
35+
id: core_tag_and_release
36+
with:
37+
tag: ${{ env.TAG }}
38+
name: "httpsnippet ${{ env.TAG }} 📦"
39+
generateReleaseNotes: true
40+
prerelease: false
41+
draft: false
42+
env:
43+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)