Build, Test and Publish #1387
Workflow file for this run
This file contains 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: Build, Test and Publish | |
on: | |
merge_group: | |
push: | |
pull_request: | |
workflow_dispatch: | |
permissions: | |
contents: read | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [14.x, 16.x, 18.x, 20.x] | |
steps: | |
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | |
with: | |
submodules: recursive | |
- name: Set up node | |
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
registry-url: 'https://registry.npmjs.org' | |
always-auth: false | |
cache: 'npm' | |
- name: Update npm | |
if: startsWith(matrix.node-version, '18.') || startsWith(matrix.node-version, '20.') | |
run: npm i -g npm | |
- name: Install dependencies | |
run: npm ci | |
- name: Build | |
run: npm run build | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | |
with: | |
submodules: recursive | |
- name: Set up node | |
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3 | |
with: | |
node-version: '20' | |
cache: 'npm' | |
- name: Update npm | |
run: npm i -g npm | |
- name: Install dependencies | |
run: npm ci | |
- name: Audit dependencies | |
run: npm audit | |
- name: Check for circular dependencies | |
run: npx madge --circular . --extensions ts,js | |
# Run Prettier | |
- name: Run Prettier | |
run: npm run format:check | |
# Run ESLint | |
- name: Run eslint | |
run: npm run lint | |
- name: Run tests | |
run: npm test | |
publish: | |
runs-on: ubuntu-latest | |
if: startsWith(github.ref, 'refs/tags/v') | |
needs: [build, test] | |
permissions: | |
contents: read | |
id-token: write | |
steps: | |
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | |
with: | |
submodules: recursive | |
- name: Set up node | |
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3 | |
with: | |
node-version: '20' | |
registry-url: 'https://registry.npmjs.org' | |
scope: '@openfga' | |
always-auth: false | |
cache: 'npm' | |
- name: Update npm | |
run: npm i -g npm | |
- name: Install dependencies | |
run: npm ci | |
- name: Publish to npm | |
run: npm publish | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
create-release: | |
runs-on: ubuntu-latest | |
if: startsWith(github.ref, 'refs/tags/v') | |
needs: publish | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | |
- uses: Roang-zero1/github-create-release-action@57eb9bdce7a964e48788b9e78b5ac766cb684803 # v3.0.1 | |
with: | |
version_regex: ^v[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+ | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |