Skip to content

Commit

Permalink
Merge pull request #117 from fingerprintjs/INTER-810-semantic-release
Browse files Browse the repository at this point in the history
[INTER-810] Add changesets and schema sync action
  • Loading branch information
TheUnderScorer authored Sep 10, 2024
2 parents 43e8ed4 + 4be9e77 commit 71ccccf
Show file tree
Hide file tree
Showing 12 changed files with 945 additions and 8 deletions.
15 changes: 15 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"fixed": [],
"linked": [],
"access": "restricted",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": [],
"privatePackages": {
"tag": true,
"version": true
}
}
34 changes: 34 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Release
on:
push:
branches:
- main

jobs:
get-token:
name: Get token
environment: production
runs-on: ubuntu-latest
outputs:
token: ${{ steps.app-token.outputs.token }}
steps:
- name: 'Get token for the GitHub App'
uses: actions/create-github-app-token@f2acddfb5195534d487896a656232b016a682f3c
id: app-token
with:
app-id: ${{ inputs.app-id }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
release:
needs: [get-token]
name: 'Release project'
uses: fingerprintjs/dx-team-toolkit/.github/workflows/release-sdk-changesets.yml@v1
with:
version-command: pnpm changeset-version
publish-command: pnpm exec changeset publish
language: node
language-version: '21'
prepare-command: |
pnpm build
secrets:
# We can't use default token, because it will result on not triggering the "upload-changesets.yml" workflow on release
GH_RELEASE_TOKEN: ${{ needs.get-token.outputs.token }}
29 changes: 29 additions & 0 deletions .github/workflows/sync-server-side-sdks-schema.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
on:
workflow_dispatch:
inputs:
tag:
description: 'Release tag'
required: true
type: string
pre-release:
description: 'Whether to create a pre-release first for the SDKs'
required: false
default: false
name: Sync Server-Side SDKs schema
jobs:
sync-node:
name: 'Sync schema in Node SDK'
uses: fingerprintjs/dx-team-toolkit/.github/workflows/update-server-side-sdk-schema.yml@v1
with:
tag: ${{ inputs.tag }}
language: node
language-version: 21
generate-command: 'pnpm generateTypes'
schema-path: resources/fingerprint-server-api.yaml
examples-path: tests/mocked-responses-tests/mocked-responses-data
app-id: ${{ vars.APP_ID }}
repository: fingerprintjs-pro-server-api-node-sdk
pre-release: ${{ inputs.pre-release }}
ignored-scopes: visitors-api
secrets:
APP_PRIVATE_KEY: ${{ secrets.APP_PRIVATE_KEY }}
56 changes: 56 additions & 0 deletions .github/workflows/upload-changesets.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Upload changesets
on:
release:
types:
- published

jobs:
upload-changesets:
name: Upload changesets
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.release.tag_name }}

- name: 'Install pnpm'
uses: pnpm/action-setup@129abb77bf5884e578fcaf1f37628e41622cc371
with:
version: 9
run_install: true

- name: Upload an Asset in GitHub Release
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const script = require('./scripts/uploadChangesets.cjs')
script({github, context, token: ${{ secrets.GITHUB_TOKEN }}})
cleanup-changesets:
runs-on: ubuntu-latest
needs: upload-changesets
environment: production
steps:
- name: 'Get token for the GitHub App'
if: ${{ vars.appId != '' }}
uses: actions/create-github-app-token@f2acddfb5195534d487896a656232b016a682f3c
id: app-token
with:
app-id: ${{ vars.appId }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}

- uses: actions/checkout@v4
with:
ref: main
token: ${{ steps.app-token.outputs.token || secrets.GITHUB_TOKEN }}

- name: Remove changesets zip files
run: rm .changeset/changesets-*.zip

- name: Commit changes
uses: EndBug/add-and-commit@a94899bca583c204427a224a7af87c02f9b325d5
with:
add: '.'
github_token: ${{ steps.app-token.outputs.token || secrets.GITHUB_TOKEN }}
message: 'chore(skip-ci): remove changesets zip files'
7 changes: 7 additions & 0 deletions .prettierrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// This file needs to be in CommonJS format, otherwise changesets crash because they don't support ESM for now.
const commonDxTeamPrettierConfig = require('@fingerprintjs/prettier-config-dx-team');

module.exports = {
...commonDxTeamPrettierConfig,
semi: true,
};
6 changes: 0 additions & 6 deletions .prettierrc.js

This file was deleted.

1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,6 @@ To validate that schema matches the actual API implementation we use a [special

### Publishing changes

- We use [changesets](https://github.com/changesets/changesets) for handling release notes. We have a handy script that simplifies the process of creating notes available via `pnpm changeset`
- When a PR is merged into `main`, the latest schema is automatically published to the [GitHub pages](https://fingerprintjs.github.io/fingerprint-pro-server-api-openapi/).
- The changes are currently NOT automatically published to the [Documentation API Reference](https://dev.fingerprint.com/reference) repository. You need to publish them manually using Readme CLI or Readme dashboard. The DX team is happy to assist.
17 changes: 15 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "fingerprint-pro-server-api-openapi",
"version": "0.0.1",
"private": true,
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"type": "module",
Expand All @@ -11,15 +12,20 @@
"lintSchemaDist": "vacuum lint ./dist/schemas/*.yaml -d --errors --base dist/schemas",
"validateSchema": "tsx ./bin/validateSchema.ts",
"test": "NODE_OPTIONS=--experimental-vm-modules jest",
"test:dts": "echo 'No typescript tests' && exit 0",
"lint": "eslint --ext .js,.ts --ignore-path .gitignore --max-warnings 0 .",
"lint:fix": "pnpm lint --fix",
"prettier": "prettier . --check",
"prettier:fix": "pnpm prettier . --write"
"prettier:fix": "pnpm prettier . --write",
"changeset": "node scripts/changeset.js",
"changeset-version": "node scripts/zipChangesets.js && pnpm exec changeset version"
},
"engines": {
"node": ">=18.0.0"
},
"devDependencies": {
"@changesets/cli": "^2.27.7",
"@fingerprintjs/conventional-changelog-dx-team": "^0.1.0",
"@fingerprintjs/eslint-config-dx-team": "^0.1.0",
"@fingerprintjs/fingerprintjs-pro-server-api": "^4.1.2",
"@fingerprintjs/prettier-config-dx-team": "^0.1.0",
Expand All @@ -36,7 +42,9 @@
"css-loader": "^6.11.0",
"dotenv": "^16.4.5",
"express": "^4.19.2",
"glob": "^11.0.0",
"html-webpack-plugin": "^5.6.0",
"human-id": "^4.1.1",
"jest": "^29.7.0",
"js-yaml": "^4.1.0",
"json-loader": "^0.5.7",
Expand All @@ -51,7 +59,12 @@
"webpack-dev-server": "^5.0.4",
"yaml": "^2.4.5",
"yaml-loader": "^0.8.1",
"zip-lib": "^1.0.4",
"znv": "^0.4.0",
"zod": "^3.23.8"
},
"dependencies": {
"@types/prompts": "^2.4.9",
"prompts": "^2.4.2"
}
}
Loading

0 comments on commit 71ccccf

Please sign in to comment.