Skip to content

Commit

Permalink
build: migrate to changesets
Browse files Browse the repository at this point in the history
  • Loading branch information
TheUnderScorer committed Oct 2, 2024
1 parent 8a10809 commit 1d10e3f
Show file tree
Hide file tree
Showing 12 changed files with 917 additions and 71 deletions.
20 changes: 20 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": [
"@fingerprintjs/changesets-changelog-format",
{
"repo": "fingerprintjs/fingerprint-pro-server-api-python-sdk"
}
],
"commit": false,
"fixed": [],
"linked": [],
"access": "restricted",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": [],
"privatePackages": {
"version": true,
"tag": true
}
}
8 changes: 8 additions & 0 deletions .github/workflows/analyze-commits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,11 @@ jobs:
analyze-commits:
name: Generate docs and coverage report
uses: fingerprintjs/dx-team-toolkit/.github/workflows/analyze-commits.yml@v1
with:
previewNotes: false

preview-changeset:
name: Preview changeset
uses: fingerprintjs/dx-team-toolkit/.github/workflows/preview-changeset-release.yml@v1
with:
pr-title: ${{ github.event.pull_request.title }}
35 changes: 35 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: 'Publish'
on:
release:
types:
- published

jobs:
publish:
name: 'Publish to PyPI'
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/fingerprint-pro-server-api-sdk
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- name: 'Checkout repository'
uses: actions/checkout@v4

- name: 'Install Python'
uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: 'Build'
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install wheel
pip install twine
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@897895f1e160c830e369f9779632ebc134688e1b


11 changes: 5 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,19 @@ on:
- dev

jobs:
release-server-sdk-python:
name: 'Publish new version'
uses: fingerprintjs/dx-team-toolkit/.github/workflows/release-server-sdk.yml@v1
release:
name: 'Release project'
uses: fingerprintjs/dx-team-toolkit/.github/workflows/release-sdk-changesets.yml@v1
with:
appId: ${{ vars.APP_ID }}
version-command: bash ./changeset-version.sh
publish-command: bash ./changeset-publish.sh
language: python
language-version: '3.12'
semantic-release-extra-plugins: |
[email protected]
prepare-command: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install wheel
pip install twine
secrets:
APP_PRIVATE_KEY: ${{ secrets.APP_PRIVATE_KEY }}
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
12 changes: 0 additions & 12 deletions .github/workflows/reset-prerelease-branch.yml

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,4 @@ target/
.DS_Store

.env
node_modules/**
48 changes: 0 additions & 48 deletions .releaserc

This file was deleted.

2 changes: 2 additions & 0 deletions changeset-publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env bash
bash ./generate.sh && pnpm exec changeset publish
2 changes: 2 additions & 0 deletions changeset-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env bash
pnpm exec changeset version && bash ./generate.sh
8 changes: 3 additions & 5 deletions generate.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

VERSION='7.0.1'
VERSION=$(jq -r '.version' package.json)

while getopts "v:" arg; do
case $arg in
Expand All @@ -11,10 +11,10 @@ while getopts "v:" arg; do
done

# Make prerelease version compatible with PEP 440
if [[ $VERSION =~ (.*-dev\.)([0-9]+) ]]; then
if [[ $VERSION =~ (.*-test\.)([0-9]+) ]]; then
BASE_VERSION=${BASH_REMATCH[1]}
DEV_NUMBER=${BASH_REMATCH[2]}
VERSION="${BASE_VERSION%-dev.}.dev${DEV_NUMBER}"
VERSION="${BASE_VERSION%-rc.}.rc${DEV_NUMBER}"
fi

# jar was downloaded from here https://repo1.maven.org/maven2/io/swagger/codegen/v3/swagger-codegen-cli/3.0.34/
Expand Down Expand Up @@ -47,10 +47,8 @@ platform=$(uname)
# Replace version in other files
(
if [ "$platform" = "Darwin" ]; then
sed -i '' "s/^VERSION='[^']*'/VERSION='${VERSION}'/" "./generate.sh"
sed -i '' "s/^VERSION = '[^']*'/VERSION = '${VERSION}'/" "./test/test_fingerprint_api.py"
else
sed -i "s/^VERSION='[^']*'/VERSION='${VERSION}'/" "./generate.sh"
sed -i "s/^VERSION = '[^']*'/VERSION = '${VERSION}'/" "./test/test_fingerprint_api.py"
fi
)
9 changes: 9 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "fingerprint-pro-server-api-python-sdk",
"version": "7.0.1",
"private": true,
"devDependencies": {
"@changesets/cli": "^2.27.8",
"@fingerprintjs/changesets-changelog-format": "^0.2.0"
}
}
Loading

0 comments on commit 1d10e3f

Please sign in to comment.