From 9b9c332c97cf019934135ee6c9f23ca55048d54e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20L=C3=B3pez?= Date: Tue, 27 Jan 2026 16:36:38 +0100 Subject: [PATCH 1/3] add GitHub Actions workflow for creating package releases --- .github/workflows/release-packages.yaml | 47 +++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 .github/workflows/release-packages.yaml diff --git a/.github/workflows/release-packages.yaml b/.github/workflows/release-packages.yaml new file mode 100644 index 0000000000..2ea88baf33 --- /dev/null +++ b/.github/workflows/release-packages.yaml @@ -0,0 +1,47 @@ +name: Create package releases + +permissions: + contents: write + +on: + push: + tags: + - "js/**" + - "python/**" + +jobs: + release: + name: Publish GitHub release for npm package + runs-on: ubuntu-latest + steps: + - name: Check if release already exists + id: release_check + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.RELEASE_GH_TOKEN }} + script: | + const tag = context.ref.replace('refs/tags/', ''); + try { + const release = await github.rest.repos.getReleaseByTag({ + owner: context.repo.owner, + repo: context.repo.repo, + tag, + }); + core.notice(`Release already exists: ${release.data.html_url}`); + core.setOutput('exists', 'true'); + } catch (error) { + if (error.status === 404) { + core.setOutput('exists', 'false'); + } else { + throw error; + } + } + + - name: Create GitHub release + id: release + if: ${{ steps.release_check.outputs.exists != 'true' }} + uses: softprops/action-gh-release@v2 + with: + tag_name: ${{ github.ref_name }} + name: ${{ github.ref_name }} + generate_release_notes: true From 7e3441c94c821d892f12bfb2edc2003c9bd5cfab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20L=C3=B3pez?= Date: Thu, 29 Jan 2026 16:59:42 +0100 Subject: [PATCH 2/3] update changeset configuration to generate changelogs and use those changelogs for release process --- .changeset/config.json | 2 +- .github/workflows/release-packages.yaml | 63 ++++++++++++++++++++++++- package.json | 1 + yarn.lock | 1 + 4 files changed, 65 insertions(+), 2 deletions(-) diff --git a/.changeset/config.json b/.changeset/config.json index 83e90e5dd2..14003dd0c3 100644 --- a/.changeset/config.json +++ b/.changeset/config.json @@ -4,7 +4,7 @@ "access": "public", "baseBranch": "main", "updateInternalDependencies": "patch", - "changelog": false, + "changelog": "@changesets/changelog-git", "bumpVersionsWithWorkspaceProtocolOnly": true, "privatePackages": { "version": true, diff --git a/.github/workflows/release-packages.yaml b/.github/workflows/release-packages.yaml index 2ea88baf33..3a81082122 100644 --- a/.github/workflows/release-packages.yaml +++ b/.github/workflows/release-packages.yaml @@ -14,6 +14,9 @@ jobs: name: Publish GitHub release for npm package runs-on: ubuntu-latest steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Check if release already exists id: release_check uses: actions/github-script@v7 @@ -37,6 +40,62 @@ jobs: } } + - name: Build release body from package CHANGELOG + id: release_body + if: ${{ steps.release_check.outputs.exists != 'true' }} + shell: bash + run: | + set -euo pipefail + + tag="${GITHUB_REF_NAME}" + body_file="${RUNNER_TEMP}/release-body.md" + + if [[ "$tag" != *"@"* ]]; then + echo "Invalid tag '${tag}': missing '@' suffix" >&2 + exit 1 + fi + + version="${tag##*@}" + changelog_path="" + + if [[ "$tag" == js/* ]]; then + pkg_and_version="${tag#js/}" + pkg_name="${pkg_and_version%@*}" + scoped_name="@human-protocol/${pkg_name}" + pkg_json=$(grep -R --include package.json -n "\"name\": \"${scoped_name}\"" packages | head -n 1 | cut -d: -f1 || true) + if [[ -n "$pkg_json" ]]; then + changelog_path="$(dirname "$pkg_json")/CHANGELOG.md" + fi + elif [[ "$tag" == python/* ]]; then + changelog_path="packages/sdk/python/human-protocol-sdk/CHANGELOG.md" + fi + + if [[ -z "$changelog_path" ]]; then + echo "Unable to resolve CHANGELOG.md path for tag '${tag}'" >&2 + exit 1 + fi + + if [[ ! -f "$changelog_path" ]]; then + echo "CHANGELOG.md not found at '${changelog_path}' for tag '${tag}'" >&2 + exit 1 + fi + + # Extract the section for the exact version in the tag. + section_body=$(awk -v ver="$version" ' + $0 ~ "^##[[:space:]]+" ver "[[:space:]]*$" { in_section=1; next } + in_section && $0 ~ "^##[[:space:]]+" { exit } + in_section { print } + ' "$changelog_path" | sed '/./,$!d' || true) + + if [[ -z "$section_body" ]]; then + echo "No CHANGELOG entry found for version '${version}' in '${changelog_path}'" >&2 + exit 1 + fi + + printf "%s\n" "$section_body" > "$body_file" + + echo "path=$body_file" >> "$GITHUB_OUTPUT" + - name: Create GitHub release id: release if: ${{ steps.release_check.outputs.exists != 'true' }} @@ -44,4 +103,6 @@ jobs: with: tag_name: ${{ github.ref_name }} name: ${{ github.ref_name }} - generate_release_notes: true + body_path: ${{ steps.release_body.outputs.path }} + env: + GITHUB_TOKEN: ${{ secrets.RELEASE_GH_TOKEN }} diff --git a/package.json b/package.json index 97bdbc91ad..8d8c4fe1f4 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "packages/**" ], "devDependencies": { + "@changesets/changelog-git": "^0.2.1", "@changesets/cli": "^2.29.6", "husky": "^9.1.6", "lint-staged": "^16.2.7" diff --git a/yarn.lock b/yarn.lock index 802514daf6..f5f0345eee 100644 --- a/yarn.lock +++ b/yarn.lock @@ -21079,6 +21079,7 @@ __metadata: version: 0.0.0-use.local resolution: "human-protocol@workspace:." dependencies: + "@changesets/changelog-git": "npm:^0.2.1" "@changesets/cli": "npm:^2.29.6" husky: "npm:^9.1.6" lint-staged: "npm:^16.2.7" From 3f9718138473fa21e1993a114314e504f81d2f89 Mon Sep 17 00:00:00 2001 From: portuu3 Date: Tue, 3 Feb 2026 13:22:40 +0100 Subject: [PATCH 3/3] Add changelog to docs --- docs/Makefile | 4 ++++ docs/README.md | 6 ++++-- docs/mkdocs-python.yaml | 1 + docs/mkdocs-ts.yaml | 1 + packages/sdk/python/human-protocol-sdk/.gitignore | 2 ++ .../human-protocol-sdk/human_protocol_sdk/gql/cancel.py | 4 +--- .../human-protocol-sdk/human_protocol_sdk/gql/escrow.py | 4 +--- .../human-protocol-sdk/human_protocol_sdk/gql/reward.py | 4 +--- .../human_protocol_sdk/gql/transaction.py | 4 +--- .../human-protocol-sdk/human_protocol_sdk/gql/worker.py | 4 +--- packages/sdk/typescript/human-protocol-sdk/.gitignore | 4 +++- 11 files changed, 20 insertions(+), 18 deletions(-) create mode 100644 docs/Makefile diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 0000000000..9a0fc76017 --- /dev/null +++ b/docs/Makefile @@ -0,0 +1,4 @@ +sync-python-changelog: + cp -f packages/sdk/python/human-protocol-sdk/CHANGELOG.md packages/sdk/python/human-protocol-sdk/docs/CHANGELOG.md +sync-typescript-changelog: + cp -f packages/sdk/typescript/human-protocol-sdk/CHANGELOG.md packages/sdk/typescript/human-protocol-sdk/docs/CHANGELOG.md \ No newline at end of file diff --git a/docs/README.md b/docs/README.md index 3f0b1726cc..6afc3e0aa2 100644 --- a/docs/README.md +++ b/docs/README.md @@ -11,10 +11,12 @@ ## Deploying a new version (mike) - TypeScript: - `yarn workspace @human-protocol/sdk build:doc` + `yarn workspace @human-protocol/sdk build:doc` + `make -f ./docs/Makefile sync-typescript-changelog` `mike deploy -F ./docs/mkdocs-ts.yaml --deploy-prefix docs/ts [VERSION]` `mike set-default -F ./docs/mkdocs-ts.yaml --deploy-prefix docs/ts [VERSION]` -- Python: +- Python: + `make -f ./docs/Makefile sync-python-changelog` `mike deploy -F ./docs/mkdocs-python.yaml --deploy-prefix docs/python [VERSION]` `mike set-default -F ./docs/mkdocs-python.yaml --deploy-prefix docs/python [VERSION]` diff --git a/docs/mkdocs-python.yaml b/docs/mkdocs-python.yaml index 5661c3eb87..ef32ecca8d 100644 --- a/docs/mkdocs-python.yaml +++ b/docs/mkdocs-python.yaml @@ -94,5 +94,6 @@ nav: - Worker: - WorkerUtils: worker_utils.md - Core utilities: core.md + - Changelog: CHANGELOG.md extra_css: - assets/css/custom.css diff --git a/docs/mkdocs-ts.yaml b/docs/mkdocs-ts.yaml index f55a4650d5..7c6d2b5893 100644 --- a/docs/mkdocs-ts.yaml +++ b/docs/mkdocs-ts.yaml @@ -85,5 +85,6 @@ nav: - TransactionUtils: classes/TransactionUtils.md - Worker: - WorkerUtils: classes/WorkerUtils.md + - Changelog: CHANGELOG.md extra_css: - assets/css/custom.css diff --git a/packages/sdk/python/human-protocol-sdk/.gitignore b/packages/sdk/python/human-protocol-sdk/.gitignore index bf05ed1cf4..da63931938 100644 --- a/packages/sdk/python/human-protocol-sdk/.gitignore +++ b/packages/sdk/python/human-protocol-sdk/.gitignore @@ -19,3 +19,5 @@ contracts # Hypothesis .hypothesis + +docs/CHANGELOG.md \ No newline at end of file diff --git a/packages/sdk/python/human-protocol-sdk/human_protocol_sdk/gql/cancel.py b/packages/sdk/python/human-protocol-sdk/human_protocol_sdk/gql/cancel.py index 6d5ddf36db..223b88aafb 100644 --- a/packages/sdk/python/human-protocol-sdk/human_protocol_sdk/gql/cancel.py +++ b/packages/sdk/python/human-protocol-sdk/human_protocol_sdk/gql/cancel.py @@ -70,6 +70,4 @@ def get_cancellation_refund_by_escrow_query(): }} }} {cancellation_refund_fragment} -""".format( - cancellation_refund_fragment=cancellation_refund_fragment - ) +""".format(cancellation_refund_fragment=cancellation_refund_fragment) diff --git a/packages/sdk/python/human-protocol-sdk/human_protocol_sdk/gql/escrow.py b/packages/sdk/python/human-protocol-sdk/human_protocol_sdk/gql/escrow.py index 38a0ca8919..5d1b01f6e6 100644 --- a/packages/sdk/python/human-protocol-sdk/human_protocol_sdk/gql/escrow.py +++ b/packages/sdk/python/human-protocol-sdk/human_protocol_sdk/gql/escrow.py @@ -97,9 +97,7 @@ def get_escrow_query(): }} }} {escrow_fragment} -""".format( - escrow_fragment=escrow_fragment - ) +""".format(escrow_fragment=escrow_fragment) def get_status_query( diff --git a/packages/sdk/python/human-protocol-sdk/human_protocol_sdk/gql/reward.py b/packages/sdk/python/human-protocol-sdk/human_protocol_sdk/gql/reward.py index 3f43bbff9e..09c06278ae 100644 --- a/packages/sdk/python/human-protocol-sdk/human_protocol_sdk/gql/reward.py +++ b/packages/sdk/python/human-protocol-sdk/human_protocol_sdk/gql/reward.py @@ -14,6 +14,4 @@ }} }} {reward_added_event_fragment} -""".format( - reward_added_event_fragment=reward_added_event_fragment -) +""".format(reward_added_event_fragment=reward_added_event_fragment) diff --git a/packages/sdk/python/human-protocol-sdk/human_protocol_sdk/gql/transaction.py b/packages/sdk/python/human-protocol-sdk/human_protocol_sdk/gql/transaction.py index ef637424b2..f17cc61876 100644 --- a/packages/sdk/python/human-protocol-sdk/human_protocol_sdk/gql/transaction.py +++ b/packages/sdk/python/human-protocol-sdk/human_protocol_sdk/gql/transaction.py @@ -103,6 +103,4 @@ def get_transaction_query() -> str: }} }} {transaction_fragment} -""".format( - transaction_fragment=transaction_fragment - ) +""".format(transaction_fragment=transaction_fragment) diff --git a/packages/sdk/python/human-protocol-sdk/human_protocol_sdk/gql/worker.py b/packages/sdk/python/human-protocol-sdk/human_protocol_sdk/gql/worker.py index 9788272612..ee21af1ef7 100644 --- a/packages/sdk/python/human-protocol-sdk/human_protocol_sdk/gql/worker.py +++ b/packages/sdk/python/human-protocol-sdk/human_protocol_sdk/gql/worker.py @@ -18,9 +18,7 @@ def get_worker_query() -> str: }} }} {worker_fragment} -""".format( - worker_fragment=worker_fragment - ) +""".format(worker_fragment=worker_fragment) def get_workers_query(filter: WorkerFilter) -> str: diff --git a/packages/sdk/typescript/human-protocol-sdk/.gitignore b/packages/sdk/typescript/human-protocol-sdk/.gitignore index 4d3fb3fcc4..bd37425c1d 100644 --- a/packages/sdk/typescript/human-protocol-sdk/.gitignore +++ b/packages/sdk/typescript/human-protocol-sdk/.gitignore @@ -8,4 +8,6 @@ dist logs docs -!docs/index.md \ No newline at end of file +!docs/index.md + +docs/CHANGELOG.md \ No newline at end of file