From 6c40f8ac610d5e0a1f3685dd4397f781e5d2702d Mon Sep 17 00:00:00 2001 From: cdecker Date: Wed, 18 Nov 2026 15:58:16 +0000 Subject: [PATCH 01/20] ci: Publish npm when the version is missing from the registry typescript.yml compared the package.json version against the parent commit to decide whether to build, test and publish. A rebase-merge puts the version bump below the tip, so the check saw no change and skipped the publish: npm stayed at 0.1.1 while package.json moved to 0.2.0 and 0.3.0. Check the registry's version list instead. A version missing from npm is built, tested and published, whichever commit bumped it, and a failed publish is retried by the next run. A failed registry request fails the job rather than counting as unpublished. --- .github/workflows/typescript.yml | 33 +++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/.github/workflows/typescript.yml b/.github/workflows/typescript.yml index 160f87523..f932f4821 100644 --- a/.github/workflows/typescript.yml +++ b/.github/workflows/typescript.yml @@ -16,36 +16,39 @@ on: name: Typescript Library jobs: + # Build, test and publish only when the version in package.json is not + # on npm yet. Comparing against the registry rather than against the + # parent commit keeps this correct for rebase-merges, where the version + # bump is not the tip commit, and lets a re-run publish a version that + # an earlier run failed to publish. check-version: runs-on: ubuntu-latest outputs: - version-changed: ${{ steps.check.outputs.changed }} + unpublished: ${{ steps.check.outputs.unpublished }} defaults: run: working-directory: libs/gl-sdk-napi steps: - uses: actions/checkout@v4 - with: - fetch-depth: 2 - + - id: check run: | - CURRENT_VERSION=$(cat package.json | jq -r '.version') - git checkout HEAD^ - PREVIOUS_VERSION=$(cat package.json | jq -r '.version') - git checkout - - if [ "$CURRENT_VERSION" != "$PREVIOUS_VERSION" ]; then - echo "Version changed from $PREVIOUS_VERSION to $CURRENT_VERSION" - echo "changed=true" >> $GITHUB_OUTPUT + NAME=$(jq -r '.name' package.json) + VERSION=$(jq -r '.version' package.json) + # The package document lists every published version. A failed + # request fails the job rather than passing for "unpublished". + DOC=$(curl -fsS "https://registry.npmjs.org/${NAME/\//%2F}") + if ! jq -e --arg v "$VERSION" '.versions | has($v)' <<<"$DOC" >/dev/null; then + echo "${NAME}@${VERSION} is not on npm yet" + echo "unpublished=true" >> $GITHUB_OUTPUT else - echo "::warning::Will not trigger publishing because version is unchanged" - echo "changed=false" >> $GITHUB_OUTPUT - exit 0 + echo "::notice::${NAME}@${VERSION} is already on npm, skipping build and publish" + echo "unpublished=false" >> $GITHUB_OUTPUT fi build: needs: check-version - if: needs.check-version.outputs.version-changed == 'true' + if: needs.check-version.outputs.unpublished == 'true' strategy: fail-fast: false matrix: From 24bcd35a170c059f8a77b32a2f067032f5a86ac2 Mon Sep 17 00:00:00 2001 From: cdecker Date: Wed, 18 Nov 2026 15:58:16 +0000 Subject: [PATCH 02/20] gl-sdk: Fix the contents of the Python wheel The wheel left out the generated bindings: glsdk/glsdk.py is listed in .gitignore, and hatchling skips ignored files unless they are force-included, so `import glsdk` failed with "No module named 'glsdk.glsdk'". Force-include it like the shared library. On Windows the hook packaged the library as glsdk/libglsdk.dll, while the UniFFI loader opens glsdk/glsdk.dll, the name cargo gives it. glsdk.__version__ was hard-coded to 0.4.0, read it from the installed package's metadata instead. --- libs/gl-sdk/CHANGELOG.md | 4 ++++ libs/gl-sdk/glsdk/__init__.py | 7 ++++++- libs/gl-sdk/hooks/libglsdk_force_include.py | 19 ++++++++++++++----- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/libs/gl-sdk/CHANGELOG.md b/libs/gl-sdk/CHANGELOG.md index 1dd8200a5..eea08b368 100644 --- a/libs/gl-sdk/CHANGELOG.md +++ b/libs/gl-sdk/CHANGELOG.md @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## Unreleased +### Fixed + +- Python: `glsdk.__version__` reports the installed package version. It was hard-coded to 0.4.0. + ## [0.5.1] - 2026-11-18 ### Changed diff --git a/libs/gl-sdk/glsdk/__init__.py b/libs/gl-sdk/glsdk/__init__.py index 268e838e9..33442017c 100644 --- a/libs/gl-sdk/glsdk/__init__.py +++ b/libs/gl-sdk/glsdk/__init__.py @@ -6,4 +6,9 @@ from .glsdk import * # noqa: F401, F403 -__version__ = "0.4.0" +from importlib.metadata import PackageNotFoundError, version as _version + +try: + __version__ = _version("gl-sdk") +except PackageNotFoundError: # imported from a source checkout + __version__ = "unknown" diff --git a/libs/gl-sdk/hooks/libglsdk_force_include.py b/libs/gl-sdk/hooks/libglsdk_force_include.py index 15314d8c6..45648796b 100644 --- a/libs/gl-sdk/hooks/libglsdk_force_include.py +++ b/libs/gl-sdk/hooks/libglsdk_force_include.py @@ -4,20 +4,29 @@ class CustomBuildHook(BuildHookInterface): def initialize(self, version, build_data): """ - Sets force-include option for glsdk/libglsdk shared lib. + Sets force-include option for glsdk/libglsdk shared lib and the + generated glsdk/glsdk.py bindings. Does the same as [tool.hatch.build.targets.wheel.force-include], however assumes system OS and based on that sets the correct extension. + + Both files are listed in .gitignore as generated artifacts, and + hatchling leaves ignored files out of the wheel unless they are + force-included. """ + build_data['force_include']["glsdk/glsdk.py"] = "glsdk/glsdk.py" + system = platform.system() + # Must match the file name `_uniffi_load_indirect` in glsdk.py + # loads, which on Windows has no `lib` prefix. match system: case "Darwin": - lib_ext = ".dylib" + lib_name = "libglsdk.dylib" case "Windows": - lib_ext = ".dll" + lib_name = "glsdk.dll" case _: - lib_ext = ".so" + lib_name = "libglsdk.so" - shared_file = f"glsdk/libglsdk{lib_ext}" + shared_file = f"glsdk/{lib_name}" build_data['force_include'][shared_file] = shared_file \ No newline at end of file From 721cb66af63ba1acafa892e53ebef1b3355a4501 Mon Sep 17 00:00:00 2001 From: cdecker Date: Wed, 18 Nov 2026 15:58:16 +0000 Subject: [PATCH 03/20] gl-sdk: Regenerate the Python bindings The committed bindings predate the doc comment change on Scheduler.lightning_available, which changed its UniFFI checksum, so they refused to load against a current build of the library. --- libs/gl-sdk/glsdk/glsdk.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/libs/gl-sdk/glsdk/glsdk.py b/libs/gl-sdk/glsdk/glsdk.py index 86b90b14e..ebba84905 100644 --- a/libs/gl-sdk/glsdk/glsdk.py +++ b/libs/gl-sdk/glsdk/glsdk.py @@ -534,7 +534,7 @@ def _uniffi_check_api_checksums(lib): raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_glsdk_checksum_method_nodeeventstream_next() != 12635: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_glsdk_checksum_method_scheduler_lightning_available() != 7327: + if lib.uniffi_glsdk_checksum_method_scheduler_lightning_available() != 8721: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_glsdk_checksum_method_scheduler_recover() != 55514: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") @@ -8616,8 +8616,12 @@ def lightning_available(self, node_id: "bytes"): before it creates a node. It needs no credentials, and the `node_id` is passed explicitly. - The answer is advisory and may change over time. Treat an - error as "unknown" rather than as a negative answer. + The answer is monotonic: once the node has been registered + it is reported as available, and stays available regardless + of the node's status or the provider's current capacity. + Before registration the answer is advisory and may change + over time. Treat an error as "unknown" rather than as a + negative answer. """ raise NotImplementedError @@ -8685,8 +8689,12 @@ def lightning_available(self, node_id: "bytes") -> "bool": before it creates a node. It needs no credentials, and the `node_id` is passed explicitly. - The answer is advisory and may change over time. Treat an - error as "unknown" rather than as a negative answer. + The answer is monotonic: once the node has been registered + it is reported as available, and stays available regardless + of the node's status or the provider's current capacity. + Before registration the answer is advisory and may change + over time. Treat an error as "unknown" rather than as a + negative answer. """ _UniffiConverterBytes.check_lower(node_id) From 8f47848167ecdbd84cb627d4f66eb22f7fb58e7c Mon Sep 17 00:00:00 2001 From: cdecker Date: Wed, 18 Nov 2026 15:58:16 +0000 Subject: [PATCH 04/20] ci: Publish the Python packages to PyPI from GitHub The gl-client Python package was published from the internal GitLab mirror by a manual job that rewrote the version with sed and built a single Linux wheel, and the gl-sdk Python package was not published or even built anywhere. python.yml now publishes both through PyPI trusted publishing, in the `pypi` environment: - a gl-client-py-vX.Y.Z tag publishes gl-client from the wheels and sdist the workflow already builds; - a gl-sdk-vX.Y.Z tag publishes gl-sdk from a new set of wheels for Linux x86_64 and aarch64 (cargo zigbuild against glibc 2.17), macOS arm64 and x86_64, and Windows x64. Each wheel bundles the library with bindings regenerated from it, is retagged from py3-none-any to its platform, and is smoke tested where the runner can load it. Both jobs refuse files whose version differs from the tag. The release tags also match release.yml's crate tag pattern, so release.yml now skips crates with `publish = false`, which gl-client-py and gl-sdk-node set: they are released to PyPI and npm, not crates.io. A gl-sdk-vX.Y.Z tag keeps publishing the gl-sdk crate as well. --- .github/workflows/python.yml | 194 +++++++++++++++++++++++++++++++++ .github/workflows/release.yml | 31 ++++++ gitlab/build-pypi.yml | 19 ---- libs/gl-client-py/CHANGELOG.md | 4 + libs/gl-client-py/Cargo.toml | 1 + libs/gl-sdk-napi/Cargo.toml | 1 + libs/gl-sdk/CHANGELOG.md | 4 + 7 files changed, 235 insertions(+), 19 deletions(-) delete mode 100644 gitlab/build-pypi.yml diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index c1a9ce535..1f35bc2aa 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -4,6 +4,13 @@ on: push: branches: - main + # Release tags. `gl-client-py-vX.Y.Z` publishes the `gl-client` + # package and `gl-sdk-vX.Y.Z` the `gl-sdk` package to PyPI, see the + # publish jobs at the end. `gl-sdk-v*` also publishes the gl-sdk crate + # through release.yml. + tags: + - 'gl-client-py-v[0-9]+.[0-9]+.[0-9]+' + - 'gl-sdk-v[0-9]+.[0-9]+.[0-9]+' pull_request: types: - synchronize @@ -190,3 +197,190 @@ jobs: with: name: wheels-win-${{ matrix.target }} path: libs\gl-client-py\dist + + # The gl-sdk Python package wraps the gl-sdk shared library with UniFFI + # bindings loaded through ctypes, so one wheel per platform serves every + # Python version. hatchling tags the wheel `py3-none-any`, which is + # retagged with the platform the bundled library was built for. + gl-sdk-wheels: + name: gl-sdk wheel - ${{ matrix.plat }} + runs-on: ${{ matrix.host }} + strategy: + fail-fast: false + matrix: + include: + # Linux libraries link glibc 2.17 through cargo-zigbuild, like the + # desktop libraries in the jvm jar, so the manylinux_2_17 tag holds. + - host: ubuntu-24.04 + target: x86_64-unknown-linux-gnu + zig: true + lib: libglsdk.so + plat: manylinux_2_17_x86_64.manylinux2014_x86_64 + smoke: true + - host: ubuntu-24.04-arm + target: aarch64-unknown-linux-gnu + zig: true + lib: libglsdk.so + plat: manylinux_2_17_aarch64.manylinux2014_aarch64 + smoke: true + - host: macos-14 + target: aarch64-apple-darwin + lib: libglsdk.dylib + plat: macosx_11_0_arm64 + smoke: true + # Cross built on the arm64 runner, not smoke tested. + - host: macos-14 + target: x86_64-apple-darwin + lib: libglsdk.dylib + plat: macosx_11_0_x86_64 + smoke: false + - host: windows-latest + target: x86_64-pc-windows-msvc + lib: glsdk.dll + plat: win_amd64 + smoke: true + defaults: + run: + shell: bash + steps: + - uses: actions/checkout@v4 + + - name: Install uv + uses: astral-sh/setup-uv@v7 + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable + with: + targets: ${{ matrix.target }} + + - name: Install Protoc + uses: arduino/setup-protoc@v3 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Install cargo-zigbuild + if: matrix.zig + run: | + pip install ziglang + cargo install --locked cargo-zigbuild@0.24.0 + + - name: Build the gl-sdk library (Linux) + if: runner.os == 'Linux' + run: cargo zigbuild --release --target ${{ matrix.target }}.2.17 -p gl-sdk + + # Apple's strip instead of cargo's rust-objcopy, see jvm-darwin-* in + # build/.tasks.yml for the dyld issue this avoids. + - name: Build the gl-sdk library (macOS) + if: runner.os == 'macOS' + env: + MACOSX_DEPLOYMENT_TARGET: '11.0' + CARGO_PROFILE_RELEASE_STRIP: 'false' + run: | + cargo build --release --target ${{ matrix.target }} -p gl-sdk + /usr/bin/strip -x target/${{ matrix.target }}/release/${{ matrix.lib }} + + # Static C runtime, so the library loads without the Visual C++ + # Redistributable. + - name: Build the gl-sdk library (Windows) + if: runner.os == 'Windows' + env: + RUSTFLAGS: -C target-feature=+crt-static + run: cargo build --release --target ${{ matrix.target }} -p gl-sdk + + # Regenerated from the library going into the wheel, so the bindings + # and the library always agree on the API checksums. + - name: Generate the Python bindings + run: | + LIB=target/${{ matrix.target }}/release/${{ matrix.lib }} + cp "$LIB" libs/gl-sdk/glsdk/${{ matrix.lib }} + cargo run --bin uniffi-bindgen -- generate \ + --library "$LIB" --language python --out-dir libs/gl-sdk/glsdk + if ! git diff --quiet -- libs/gl-sdk/glsdk/glsdk.py; then + echo "::warning::The committed libs/gl-sdk/glsdk/glsdk.py is stale, run task sdk:bindings-python" + fi + + - name: Build and retag the wheel + run: | + uv build --package gl-sdk --wheel --out-dir dist-sdk + uvx --from wheel wheel tags --remove --platform-tag '${{ matrix.plat }}' dist-sdk/*.whl + ls -la dist-sdk + + - name: Smoke test the wheel + if: matrix.smoke + run: | + WHEEL=$(ls dist-sdk/*.whl) + # The import checks the bindings against the library's API + # checksums, parse_input calls into the library. + uv run --no-project --isolated --python 3.12 --with "$WHEEL" python -c \ + "import glsdk; print(glsdk.__version__); print(glsdk.parse_input('02eec7245d6b7d2ccb30380bfbe2a3648cd7a942653f5aa340edcea1f283686619'))" + + - name: Upload wheel + uses: actions/upload-artifact@v4 + with: + name: gl-sdk-wheel-${{ matrix.target }} + path: dist-sdk/*.whl + if-no-files-found: error + + # Publishing uses PyPI trusted publishing: PyPI accepts the GitHub OIDC + # token of this workflow in the `pypi` environment, no API token needed. + publish-gl-client: + name: Publish gl-client to PyPI + if: startsWith(github.ref, 'refs/tags/gl-client-py-v') + needs: [source, linux, macos, windows] + runs-on: ubuntu-24.04 + environment: + name: pypi + url: https://pypi.org/project/gl-client/ + permissions: + contents: read + id-token: write + steps: + - uses: actions/download-artifact@v4 + with: + pattern: wheels-* + path: dist + merge-multiple: true + + - name: Check the version matches the tag + run: | + VERSION=${GITHUB_REF_NAME#gl-client-py-v} + ls -la dist + for f in dist/*; do + case "$(basename "$f")" in + gl_client-"$VERSION"-*.whl|gl_client-"$VERSION".tar.gz) ;; + *) echo "::error::$f does not match version $VERSION from the tag"; exit 1 ;; + esac + done + + - uses: pypa/gh-action-pypi-publish@release/v1 + + publish-gl-sdk: + name: Publish gl-sdk to PyPI + if: startsWith(github.ref, 'refs/tags/gl-sdk-v') + needs: [gl-sdk-wheels] + runs-on: ubuntu-24.04 + environment: + name: pypi + url: https://pypi.org/project/gl-sdk/ + permissions: + contents: read + id-token: write + steps: + - uses: actions/download-artifact@v4 + with: + pattern: gl-sdk-wheel-* + path: dist + merge-multiple: true + + - name: Check the version matches the tag + run: | + VERSION=${GITHUB_REF_NAME#gl-sdk-v} + ls -la dist + for f in dist/*; do + case "$(basename "$f")" in + gl_sdk-"$VERSION"-*.whl) ;; + *) echo "::error::$f does not match version $VERSION from the tag"; exit 1 ;; + esac + done + + - uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 16dc90cb9..18717e5bf 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -48,7 +48,38 @@ permissions: contents: write jobs: + # Some tags matching the pattern above release a package that is not a + # crate, for example `gl-client-py-v*` publishes the Python package from + # python.yml. Their workspace crate sets `publish = false`, and this job + # skips them. A tag naming no workspace crate at all still runs the + # publish job, which fails on it. + filter: + runs-on: ubuntu-latest + outputs: + publish: ${{ steps.filter.outputs.publish }} + steps: + - uses: actions/checkout@v4 + + - id: filter + run: | + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then + CRATE="${{ inputs.crate }}" + else + CRATE=$(echo "${GITHUB_REF#refs/tags/}" | sed -E 's/-v[0-9]+\.[0-9]+\.[0-9]+$//') + fi + # `publish = false` shows as an empty registry list. + PUBLISH=$(cargo metadata --no-deps --format-version 1 | \ + jq -r --arg c "$CRATE" '.packages[] | select(.name == $c) | if .publish == [] then "false" else "true" end') + if [ "$PUBLISH" = "false" ]; then + echo "::notice::$CRATE sets publish = false, not publishing it to crates.io" + echo "publish=false" >> $GITHUB_OUTPUT + else + echo "publish=true" >> $GITHUB_OUTPUT + fi + publish: + needs: filter + if: needs.filter.outputs.publish == 'true' runs-on: ubuntu-latest steps: # ========================================================================== diff --git a/gitlab/build-pypi.yml b/gitlab/build-pypi.yml deleted file mode 100644 index 2866bf202..000000000 --- a/gitlab/build-pypi.yml +++ /dev/null @@ -1,19 +0,0 @@ -build_gl_client_py: - extends: .build_setup - when: manual - rules: - - if: $CI_COMMIT_TAG =~ /glclientpy_\d{8}(_[1-9][0-9]?)?\-.*/ - before_script: - - export NEW_VER=$(echo ${CI_COMMIT_TAG} | cut -d'-' -f2) - - sed -i "s/^version = \".*\"/version = \"$NEW_VER\"/" libs/gl-client-py/pyproject.toml - - sed -i "s/^version = \".*\"/version = \"$NEW_VER\"/" libs/gl-client-py/Cargo.toml - - . $HOME/.cargo/env # sh doesn't have the correct PATH - script: - - uv run maturin build -m libs/gl-client-py/Cargo.toml --release || sleep 3600 - - uv run maturin sdist -m libs/gl-client-py/Cargo.toml - - uv run maturin upload --username __token__ --password ${PYPI_TOKEN} target/wheels/* - - ls -lh target/wheels - artifacts: - expire_in: 2 weeks - paths: - - "target/wheels/*" diff --git a/libs/gl-client-py/CHANGELOG.md b/libs/gl-client-py/CHANGELOG.md index 792190a09..ae52898f2 100644 --- a/libs/gl-client-py/CHANGELOG.md +++ b/libs/gl-client-py/CHANGELOG.md @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## Unreleased +### Added + +- Wheels are published to PyPI from GitHub Actions again, for Linux (x86_64, i686), macOS (x86_64, arm64) and Windows (x64, x86). 0.3.4 had shipped only a Linux x86_64 wheel. + ## [0.4.1] - 2026-11-18 ### Changed diff --git a/libs/gl-client-py/Cargo.toml b/libs/gl-client-py/Cargo.toml index 9812a8af1..29c7f070d 100644 --- a/libs/gl-client-py/Cargo.toml +++ b/libs/gl-client-py/Cargo.toml @@ -1,6 +1,7 @@ [package] name = "gl-client-py" version = "0.4.1" +publish = false # released to PyPI as `gl-client`, see python.yml edition = "2018" authors = ["Christian Decker", "The Greenlight Team"] description = "Python bindings for the Greenlight client library." diff --git a/libs/gl-sdk-napi/Cargo.toml b/libs/gl-sdk-napi/Cargo.toml index f46e400c2..95b879e3e 100644 --- a/libs/gl-sdk-napi/Cargo.toml +++ b/libs/gl-sdk-napi/Cargo.toml @@ -1,6 +1,7 @@ [package] name = "gl-sdk-node" version = "0.3.1" +publish = false # released to npm as `@greenlightcln/glsdk`, see typescript.yml edition = "2021" license = "MIT" diff --git a/libs/gl-sdk/CHANGELOG.md b/libs/gl-sdk/CHANGELOG.md index eea08b368..7100cfc6c 100644 --- a/libs/gl-sdk/CHANGELOG.md +++ b/libs/gl-sdk/CHANGELOG.md @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## Unreleased +### Added + +- Python: the `gl-sdk` package is published to PyPI, with wheels for Linux (glibc 2.17 or later) on x86_64 and aarch64, macOS 11 or later on arm64 and x86_64, and Windows on x64. + ### Fixed - Python: `glsdk.__version__` reports the installed package version. It was hard-coded to 0.4.0. From c0e5e1bf3195e65e4fa029b95b2db0e003f08946 Mon Sep 17 00:00:00 2001 From: cdecker Date: Wed, 18 Nov 2026 15:58:16 +0000 Subject: [PATCH 05/20] ci: Publish every crate from GitHub gl-plugin, gl-signerproxy and gl-cli were published from the internal GitLab mirror by manual jobs on date-stamped tags, which rewrote the version with sed and published without the changelog and semver checks release.yml runs. Publish them from release.yml like the other crates, and leave the mirror with only the Maven Central pipeline. --- gitlab/README.md | 28 ++++++++++++++------------- gitlab/build-crates.yml | 42 ----------------------------------------- 2 files changed, 15 insertions(+), 55 deletions(-) delete mode 100644 gitlab/build-crates.yml diff --git a/gitlab/README.md b/gitlab/README.md index ac30d512c..01019fe69 100644 --- a/gitlab/README.md +++ b/gitlab/README.md @@ -1,19 +1,21 @@ ## Gitlab Pipelines -There are 5 Greenlight packaged binaries/libraries that are published - 1 Python packages and 4 Rust crates. -The builds are triggered by certain tag formats. Make sure to include a patch as well since the Rust compiler requires that (applicable to `gl-client-py` as well). +The internal GitLab mirror of this repository only builds and publishes +the Android/JVM library, `com.blockstream:glsdk`, to Maven Central. +Every other package is published from GitHub Actions, see +[the release docs](../docs/src/reference/releases.md). -Packages and tag formats ---- -If a tagged release doesn't work, it can be retried by adding an `_N` suffix after the date part. For example: `..YYYYMMDD_1-x.x.x` or `..YYYYMMDD_25-x.x.x`. +The mirror is updated by pushing `main` and the release tags to it. -**Note:** The last part of the tag (after the `-`) is used to change the version to be pushed. If different from what's in the respective `pyproject.toml`/`Cargo.toml`, the TOML files will be overwritten via `sed` by the Gitlab job. +### Maven Central -### PyPI -* gl-client-py - `glclientpy_YYYYMMDD-x.x.x` +* `build_kotlin` runs on every tag and on `main`, on the `m4` macOS runner. +* `publish_to_maven` is a manual job on tag pipelines. It publishes the + version in `libs/gl-sdk-android/gradle.properties` (`libraryVersion`), + not the version in the tag, so run it once per release, on the + `gl-sdk-vX.Y.Z` tag's pipeline. +* `publish_snapshot_to_maven` publishes a `-SNAPSHOT` build on every + branch pipeline. -### crates.io -* gl-client - `glclient_YYYYMMDD-x.x.x` -* gl-plugin - `glplugin_YYYYMMDD-x.x.x` -* gl-signerproxy - `glsignerproxy_YYYYMMDD-x.x.x` -* gl-cli -`glcli_YYYYMMDD-x.x.x` +The Maven Central credentials and the GPG signing key are configured in +the runner's `~/.gradle/gradle.properties`. diff --git a/gitlab/build-crates.yml b/gitlab/build-crates.yml deleted file mode 100644 index 5db19fa0a..000000000 --- a/gitlab/build-crates.yml +++ /dev/null @@ -1,42 +0,0 @@ -.build_rust_prep: - extends: .build_setup - when: manual - before_script: - - export NEW_VER=$(echo ${CI_COMMIT_TAG} | cut -d'-' -f2) - - sed -i "s/^version = \".*\"/version = \"$NEW_VER\"/" libs/${PKG_NAME}/Cargo.toml - - . $HOME/.cargo/env # sh doesn't have the correct PATH - script: - - cargo test -p ${PKG_NAME} -- --test-threads=1 || sleep 3600 - - cargo build --release -p ${PKG_NAME} - - cargo publish -p ${PKG_NAME} --allow-dirty # allow-dirty needed because we change the version in Cargo.toml - artifacts: - paths: - - "target/release/${PKG_NAME}" - -build_gl_client: - extends: .build_rust_prep - rules: - - if: $CI_COMMIT_TAG =~ /glclient_\d{8}(_[1-9][0-9]?)?\-.*/ - variables: - PKG_NAME: gl-client - -build_gl_plugin: - extends: .build_rust_prep - rules: - - if: $CI_COMMIT_TAG =~ /glplugin_\d{8}(_[1-9][0-9]?)?\-.*/ - variables: - PKG_NAME: gl-plugin - -build_gl_signerproxy: - extends: .build_rust_prep - rules: - - if: $CI_COMMIT_TAG =~ /glsignerproxy_\d{8}(_[1-9][0-9]?)?\-.*/ - variables: - PKG_NAME: gl-signerproxy - -build_gl_cli: - extends: .build_rust_prep - rules: - - if: $CI_COMMIT_TAG =~ /glcli_\d{8}(_[1-9][0-9]?)?\-.*/ - variables: - PKG_NAME: gl-cli From 3604c16b400c9dce8e18152e908f5b452ea584b1 Mon Sep 17 00:00:00 2001 From: cdecker Date: Wed, 18 Nov 2026 15:58:16 +0000 Subject: [PATCH 06/20] docs: Describe the consolidated release process List every published artifact with the workflow and trigger that publishes it, document the Python release tags and their overlap with the crate tags, and replace the npm and Python gaps with how the new checks work and the PyPI setup they need. --- docs/src/reference/releases.md | 60 ++++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 24 deletions(-) diff --git a/docs/src/reference/releases.md b/docs/src/reference/releases.md index 5d1acc463..eacc88048 100644 --- a/docs/src/reference/releases.md +++ b/docs/src/reference/releases.md @@ -10,17 +10,14 @@ failure modes. | Artifact | Workflow | Trigger | Registry | | --- | --- | --- | --- | -| `gl-client`, `gl-sdk`, `gl-sdk-cli` (Rust) | `.github/workflows/release.yml` | push of a `*-v*` tag | crates.io | -| `@greenlightcln/glsdk` (npm) | `.github/workflows/typescript.yml` | push to `main`, gated on a version change | npm | -| `gl-client-py`, `gl-sdk` (Python wheels) | `.github/workflows/python.yml` | push to `main` / PR | **built only — not published** | +| `gl-client`, `gl-plugin`, `gl-signerproxy`, `gl-cli`, `gl-sdk`, `gl-sdk-cli` (Rust) | `.github/workflows/release.yml` | push of a `-vX.Y.Z` tag | crates.io | +| `gl-client` (Python, `libs/gl-client-py`) | `.github/workflows/python.yml` | push of a `gl-client-py-vX.Y.Z` tag | PyPI (trusted publishing) | +| `gl-sdk` (Python, `libs/gl-sdk`) | `.github/workflows/python.yml` | push of a `gl-sdk-vX.Y.Z` tag | PyPI (trusted publishing) | +| `@greenlightcln/glsdk` (npm) | `.github/workflows/typescript.yml` | push to `main` whose `package.json` version is not on npm yet | npm | +| `com.blockstream:glsdk` (Android, JVM) | `gitlab/deploy-maven.yml` on the internal GitLab mirror | manual `publish_to_maven` job on a tag pipeline | Maven Central | +| `GreenlightSDK` (Swift) | `swift.yml` in `Blockstream/gl-sdk-swift` | manual dispatch | GitHub Releases of that repo | | `clnvm` (Python) | `task clnvm:publish` (manual `twine`) | manual | PyPI | -!!! warning - The Python SDK wheels are built and tested in CI but there is - currently **no publish step** for them. Publishing them, if it is - ever wanted, still has to be wired up (see - [Gaps and gotchas](#gaps-and-gotchas)). - ## Tag conventions The crates.io workflow fires on any tag matching: @@ -34,6 +31,14 @@ last `-v` is taken as the crate name and the rest as the version. The workflow then enforces a **"Version Match"** check: the tag version must equal the `version` in that crate's `Cargo.toml`. +The same pattern also matches the Python release tags. A +`gl-sdk-vX.Y.Z` tag therefore publishes both the `gl-sdk` crate and the +`gl-sdk` Python package. The `gl-client-py` crate sets `publish = false`, +so `release.yml` skips `gl-client-py-vX.Y.Z` tags and only +`python.yml` acts on them. `python.yml` checks that every built wheel +carries the version from the tag, which comes from the package's +`pyproject.toml`. + ## Cutting a release 1. **Bump versions and changelogs.** For each crate going out, set @@ -53,7 +58,8 @@ equal the `version` in that crate's `Cargo.toml`. 4. **Publish in dependency order.** The higher-level crates depend on the lower-level ones, so publish (or re-run) `gl-client` first, then - `gl-sdk`, then `gl-sdk-cli`. If they race, the dependent crate fails + `gl-plugin`, `gl-signerproxy`, `gl-cli` and `gl-sdk`, then + `gl-sdk-cli`. If they race, the dependent crate fails with `failed to select a version for the requirement gl-client = ...` simply because its dependency is not on crates.io yet. The publish step is idempotent — anything already on crates.io is skipped — so a @@ -92,6 +98,7 @@ Publishing reads these GitHub Actions secrets (in | --- | --- | --- | | `CRATES_IO_TOKEN` | `release.yml` | crates.io publishing | | `NPM_TOKEN` | `typescript.yml` | npm publishing | +| *(none)* | `python.yml` | PyPI, through trusted publishing in the `pypi` environment | | `TWINE_PASSWORD` | manual `task clnvm:publish` only | PyPI; not used by CI | | `CARGO_REGISTRY_TOKEN` | *none* | orphaned — `release.yml` maps the env var from `CRATES_IO_TOKEN` instead | | `RELEASE_PLZ_TOKEN` | *none* | orphaned — `release-plz.toml` exists but no workflow runs release-plz | @@ -106,19 +113,24 @@ in dependency order. ## Gaps and gotchas -- **npm publish skips after a rebase-merge.** `typescript.yml` decides - whether to publish by diffing `package.json` against its immediate - parent (`HEAD^`). A normal PR merge puts the version bump on the tip, - so it fires; a **rebase-merge buries the bump below the tip**, the diff - sees "unchanged", and `check-version` skips build, test **and** publish. - A `workflow_dispatch` does not help, because `publish` transitively - depends on the skipped `test` job. The robust fix is to compare against - the version already published to npm (`npm view @greenlightcln/glsdk - version`) rather than `HEAD^`. -- **Python wheels are not published.** `python.yml` builds them and - `import glclient` smoke-tests them, but nothing uploads them to PyPI. - If Python releases are wanted, add a publish job (ideally PyPI trusted - publishing, which needs no token) triggered by `gl-client-py-v*` / - `gl-sdk-v*` tags. +- **npm publishes whatever version is missing from the registry.** + `typescript.yml` builds, tests and publishes when the `package.json` + version is not in the registry's version list for `@greenlightcln/glsdk`. + It compared against the parent commit before, which skipped the + publish after a rebase-merge buried the version bump below the tip, + and that left npm at 0.1.1 while `package.json` said 0.3.0. +- **PyPI trusted publishing has to be set up on pypi.org.** The publish + jobs in `python.yml` run in the `pypi` GitHub environment and + authenticate with the workflow's OIDC token. Each PyPI project needs a + trusted publisher for owner `Blockstream`, repository `greenlight`, + workflow `python.yml` and environment `pypi`. For a project that does + not exist on PyPI yet, add it as a *pending* publisher. +- **The `gl-sdk` Python wheel is retagged.** hatchling builds it as + `py3-none-any`, but it bundles the native library, so `python.yml` + retags each wheel with the platform the library was built for. The + Linux libraries are built with `cargo zigbuild` against glibc 2.17, + which is what the `manylinux_2_17` tag promises. The bindings in the + wheel are regenerated from the bundled library, and the job warns if + the committed `libs/gl-sdk/glsdk/glsdk.py` differs from them. - **Swift is a separate repository.** `gl-sdk-swift` is published from its own repo (`Blockstream/gl-sdk-swift`) and is out of scope here. From f23d11736463dd76e2093d2d4166fb23d8b17a5d Mon Sep 17 00:00:00 2001 From: cdecker Date: Wed, 18 Nov 2026 16:22:57 +0000 Subject: [PATCH 07/20] ci: Build the Swift package and attach it to gl-sdk releases The Swift package was built in Blockstream/gl-sdk-swift by a workflow dispatched by hand after each gl-sdk release, so nothing built the XCFramework before a release, and automating the dispatch from here would need a token for the other repository. Build it here instead. swift.yml builds the XCFramework and the Swift bindings on changes to the SDK and compiles them as a Swift package for the iOS simulator. On a gl-sdk-vX.Y.Z tag it attaches the zip, its checksum and glsdk.swift to the gl-sdk-vX.Y.Z release, creating the release if release.yml has not yet. gl-sdk-swift's publish.yml picks them up from there, so each repository only writes to itself. --- .github/workflows/swift.yml | 160 +++++++++++++++++++++++++++++++++ docs/src/reference/releases.md | 18 +++- libs/gl-sdk/CHANGELOG.md | 4 + 3 files changed, 179 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/swift.yml diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml new file mode 100644 index 000000000..7e6c0b0fd --- /dev/null +++ b/.github/workflows/swift.yml @@ -0,0 +1,160 @@ +name: Swift + +# Builds the gl-sdk XCFramework and Swift bindings. On a gl-sdk-vX.Y.Z +# tag they are attached to this repository's gl-sdk-vX.Y.Z release, where +# Blockstream/gl-sdk-swift picks them up: its publish workflow commits the +# bindings and a Package.swift pointing at the zip here, and tags X.Y.Z. +# Each repository only writes to itself, so no cross-repository token is +# needed. + +on: + push: + branches: + - main + paths: + - '.github/workflows/swift.yml' + - 'build/**' + - 'libs/gl-client/**' + - 'libs/gl-sdk/**' + - 'libs/proto/**' + - 'Cargo.lock' + tags: + - 'gl-sdk-v[0-9]+.[0-9]+.[0-9]+' + pull_request: + paths: + - '.github/workflows/swift.yml' + - 'build/**' + - 'libs/gl-client/**' + - 'libs/gl-sdk/**' + - 'libs/proto/**' + - 'Cargo.lock' + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +permissions: + contents: read + +jobs: + build: + name: Build XCFramework + runs-on: macos-15 + steps: + - uses: actions/checkout@v4 + + - uses: dtolnay/rust-toolchain@stable + with: + targets: aarch64-apple-ios,aarch64-apple-ios-sim,x86_64-apple-ios + + - name: Determine the version + run: | + if [[ "$GITHUB_REF" == refs/tags/gl-sdk-v* ]]; then + VERSION="${GITHUB_REF_NAME#gl-sdk-v}" + else + VERSION=$(cargo metadata --no-deps --format-version 1 | \ + jq -r '.packages[] | select(.name == "gl-sdk") | .version') + fi + echo "VERSION=$VERSION" >> "$GITHUB_ENV" + echo "Building gl-sdk $VERSION" + + - uses: Swatinem/rust-cache@v2 + + - name: Install Protoc + uses: arduino/setup-protoc@v3 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Install Task + uses: arduino/setup-task@v2 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Install XcodeGen and yq + run: brew install xcodegen yq + + - name: Set the framework version + run: | + yq e '.targets.glsdkFFI.settings.MARKETING_VERSION = env(VERSION)' -i build/project.yml + yq e '.targets.glsdkFFI.settings.CURRENT_PROJECT_VERSION = "1"' -i build/project.yml + + - name: Build + run: task build:swift + + - name: Package + run: | + mkdir -p dist + (cd target && zip -9 -r -q ../dist/glsdkFFI.xcframework.zip glsdkFFI.xcframework) + cp target/swift/glsdk.swift dist/glsdk.swift + # SwiftPM verifies the zip against this checksum, the SHA-256. + swift package compute-checksum dist/glsdkFFI.xcframework.zip > dist/glsdkFFI.xcframework.zip.checksum + shasum -a 256 dist/glsdkFFI.xcframework.zip + cat dist/glsdkFFI.xcframework.zip.checksum + ls -la dist + + # Compiles the bindings against the framework as a Swift package, + # the way gl-sdk-swift ships them, for the iOS simulator. + - name: Compile the Swift package + run: | + PKG="$RUNNER_TEMP/GreenlightSDK" + mkdir -p "$PKG/Sources/GreenlightSDK" + cp dist/glsdk.swift "$PKG/Sources/GreenlightSDK/GreenlightSDK.swift" + (cd "$PKG" && unzip -q "$GITHUB_WORKSPACE/dist/glsdkFFI.xcframework.zip") + cat > "$PKG/Package.swift" <<'EOF' + // swift-tools-version:5.5 + import PackageDescription + + let package = Package( + name: "glsdk", + platforms: [.macOS(.v12), .iOS(.v13)], + products: [ + .library(name: "GreenlightSDK", targets: ["glsdkFFI", "GreenlightSDK"]), + ], + targets: [ + .binaryTarget(name: "glsdkFFI", path: "glsdkFFI.xcframework"), + .target(name: "GreenlightSDK", dependencies: ["glsdkFFI"]), + ] + ) + EOF + cd "$PKG" + xcodebuild build -scheme GreenlightSDK \ + -destination 'generic/platform=iOS Simulator' -quiet + + - uses: actions/upload-artifact@v4 + with: + name: swift + path: dist/ + if-no-files-found: error + + # release.yml creates the gl-sdk-vX.Y.Z release once the crate is + # published. Whichever runs first creates it, the other updates it. + attach: + name: Attach to the gl-sdk release + if: startsWith(github.ref, 'refs/tags/gl-sdk-v') + needs: build + runs-on: ubuntu-latest + permissions: + contents: write + env: + GH_TOKEN: ${{ github.token }} + GH_REPO: ${{ github.repository }} + steps: + - uses: actions/download-artifact@v4 + with: + name: swift + path: dist + + - name: Upload the release assets + run: | + TAG="$GITHUB_REF_NAME" + if ! gh release view "$TAG" >/dev/null 2>&1; then + gh release create "$TAG" --verify-tag --title "gl-sdk ${TAG#gl-sdk-v}" \ + --notes "See the [gl-sdk changelog](https://github.com/$GH_REPO/blob/$TAG/libs/gl-sdk/CHANGELOG.md)." \ + || gh release view "$TAG" >/dev/null # lost the race to release.yml + fi + gh release upload "$TAG" --clobber \ + dist/glsdkFFI.xcframework.zip \ + dist/glsdkFFI.xcframework.zip.checksum \ + dist/glsdk.swift + gh release view "$TAG" --json assets --jq '.assets[].name' diff --git a/docs/src/reference/releases.md b/docs/src/reference/releases.md index eacc88048..d296f6fb9 100644 --- a/docs/src/reference/releases.md +++ b/docs/src/reference/releases.md @@ -15,7 +15,7 @@ failure modes. | `gl-sdk` (Python, `libs/gl-sdk`) | `.github/workflows/python.yml` | push of a `gl-sdk-vX.Y.Z` tag | PyPI (trusted publishing) | | `@greenlightcln/glsdk` (npm) | `.github/workflows/typescript.yml` | push to `main` whose `package.json` version is not on npm yet | npm | | `com.blockstream:glsdk` (Android, JVM) | `gitlab/deploy-maven.yml` on the internal GitLab mirror | manual `publish_to_maven` job on a tag pipeline | Maven Central | -| `GreenlightSDK` (Swift) | `swift.yml` in `Blockstream/gl-sdk-swift` | manual dispatch | GitHub Releases of that repo | +| `GreenlightSDK` (Swift) | `.github/workflows/swift.yml` builds it, `publish.yml` in `Blockstream/gl-sdk-swift` publishes it | push of a `gl-sdk-vX.Y.Z` tag; `gl-sdk-swift` picks it up within the hour | tag and GitHub Release `X.Y.Z` in `gl-sdk-swift` | | `clnvm` (Python) | `task clnvm:publish` (manual `twine`) | manual | PyPI | ## Tag conventions @@ -132,5 +132,17 @@ in dependency order. which is what the `manylinux_2_17` tag promises. The bindings in the wheel are regenerated from the bundled library, and the job warns if the committed `libs/gl-sdk/glsdk/glsdk.py` differs from them. -- **Swift is a separate repository.** `gl-sdk-swift` is published from - its own repo (`Blockstream/gl-sdk-swift`) and is out of scope here. +- **The Swift package is published from `gl-sdk-swift`.** SwiftPM + resolves packages by repository, so the package lives there, while + greenlight builds it. `swift.yml` builds the XCFramework and the + bindings on every change to the SDK, compiles them as a Swift package + for the iOS simulator, and on a `gl-sdk-vX.Y.Z` tag attaches + `glsdkFFI.xcframework.zip`, its checksum and `glsdk.swift` to the + `gl-sdk-vX.Y.Z` release here. `publish.yml` in `gl-sdk-swift` polls + hourly for such releases, commits a `Package.swift` whose binary + target points at the zip in greenlight's release, and tags and + releases `X.Y.Z` there. Neither repository writes to the other, so no + cross-repository token is needed. To publish sooner or retry, run + `publish.yml` in `gl-sdk-swift` by hand. GitHub disables its schedule + after 60 days without activity in that repository; re-enable it on + the Actions tab. diff --git a/libs/gl-sdk/CHANGELOG.md b/libs/gl-sdk/CHANGELOG.md index 7100cfc6c..a88406bab 100644 --- a/libs/gl-sdk/CHANGELOG.md +++ b/libs/gl-sdk/CHANGELOG.md @@ -10,6 +10,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - Python: the `gl-sdk` package is published to PyPI, with wheels for Linux (glibc 2.17 or later) on x86_64 and aarch64, macOS 11 or later on arm64 and x86_64, and Windows on x64. +### Changed + +- Swift: the `glsdkFFI` binary target in `gl-sdk-swift`'s `Package.swift` downloads `glsdkFFI.xcframework.zip` from the `gl-sdk-vX.Y.Z` release of `Blockstream/greenlight`, where it is now built, instead of from the `gl-sdk-swift` release. + ### Fixed - Python: `glsdk.__version__` reports the installed package version. It was hard-coded to 0.4.0. From cb48c9c4595821077567a6ee3f815aa5fbd402ef Mon Sep 17 00:00:00 2001 From: cdecker Date: Wed, 18 Nov 2026 17:08:20 +0000 Subject: [PATCH 08/20] ci: Build on macos-15 instead of the retired macos-14 image GitHub no longer runs jobs on macos-14 ("The configuration 'macos-14-arm64-us-default' is not supported"), which failed the gl-sdk macOS wheels at once and would fail the npm aarch64-apple-darwin build whenever it runs. --- .github/workflows/python.yml | 4 ++-- .github/workflows/typescript.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 1f35bc2aa..f24b070ee 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -223,13 +223,13 @@ jobs: lib: libglsdk.so plat: manylinux_2_17_aarch64.manylinux2014_aarch64 smoke: true - - host: macos-14 + - host: macos-15 target: aarch64-apple-darwin lib: libglsdk.dylib plat: macosx_11_0_arm64 smoke: true # Cross built on the arm64 runner, not smoke tested. - - host: macos-14 + - host: macos-15 target: x86_64-apple-darwin lib: libglsdk.dylib plat: macosx_11_0_x86_64 diff --git a/.github/workflows/typescript.yml b/.github/workflows/typescript.yml index f932f4821..cc61ebd04 100644 --- a/.github/workflows/typescript.yml +++ b/.github/workflows/typescript.yml @@ -65,7 +65,7 @@ jobs: target: x86_64-apple-darwin strip: strip -x *.node - - host: macos-14 + - host: macos-15 target: aarch64-apple-darwin strip: strip -x *.node From c9988af1bcaa0e7471ed6dd1e3fce8ed03dc68d5 Mon Sep 17 00:00:00 2001 From: cdecker Date: Wed, 18 Nov 2026 17:43:48 +0000 Subject: [PATCH 09/20] ci: Pick the Swift package's scheme from the list Xcode reports xcodebuild names the schemes of a Swift package itself, and the package built to compile the bindings has no scheme named GreenlightSDK. List the schemes and build the library product's, or the whole package's. --- .github/workflows/swift.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml index 7e6c0b0fd..f0de8dfd7 100644 --- a/.github/workflows/swift.yml +++ b/.github/workflows/swift.yml @@ -118,7 +118,16 @@ jobs: ) EOF cd "$PKG" - xcodebuild build -scheme GreenlightSDK \ + # Xcode derives the schemes from the package, list them and + # build the library product's, or the whole package's. + SCHEMES=$(xcodebuild -list -json | jq -r '(.workspace // .project).schemes[]') + echo "Schemes: $(echo $SCHEMES)" + SCHEME=$(grep -xE 'GreenlightSDK|glsdk-Package|glsdk' <<<"$SCHEMES" | head -n1) + if [ -z "$SCHEME" ]; then + echo "::error::No GreenlightSDK or glsdk scheme in the package" + exit 1 + fi + xcodebuild build -scheme "$SCHEME" \ -destination 'generic/platform=iOS Simulator' -quiet - uses: actions/upload-artifact@v4 From 51f6aa1e3031f2666a140e82e6203f54a3b47e22 Mon Sep 17 00:00:00 2001 From: cdecker Date: Thu, 19 Nov 2026 13:50:06 +0100 Subject: [PATCH 10/20] signerproxy: Pin the log dependency to 0.4 crates.io rejected gl-signerproxy 0.4.0 with "wildcard (`*`) dependency constraints are not allowed on crates.io", for `log = "*"`. 0.4 is the version range Cargo.lock already resolves to (0.4.29). --- libs/gl-signerproxy/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/gl-signerproxy/Cargo.toml b/libs/gl-signerproxy/Cargo.toml index f491e759a..cdf244b9c 100644 --- a/libs/gl-signerproxy/Cargo.toml +++ b/libs/gl-signerproxy/Cargo.toml @@ -23,7 +23,7 @@ env_logger = { workspace = true } tokio = { version = "1", features = ["rt", "net", "io-util"] } tonic = { version = "0.11", features = ["tls", "transport"] } prost = "0.12" -log = "*" +log = "0.4" tower = "0.4" which = "4.4.2" libc = "0.2" From fe706c70d9b7c4a7f4eca9e1a5059018b2b9ee11 Mon Sep 17 00:00:00 2001 From: cdecker Date: Thu, 19 Nov 2026 13:52:28 +0100 Subject: [PATCH 11/20] cargo: Never publish gl-examples and uniffi-bindgen Neither is meant for crates.io, and crates.io already has an unrelated uniffi-bindgen. The release plan publishes every workspace crate that does not set publish = false. --- examples/rust/Cargo.toml | 1 + libs/uniffi-bindgen/Cargo.toml | 1 + 2 files changed, 2 insertions(+) diff --git a/examples/rust/Cargo.toml b/examples/rust/Cargo.toml index 88a9128f4..22bcbcf1f 100644 --- a/examples/rust/Cargo.toml +++ b/examples/rust/Cargo.toml @@ -2,6 +2,7 @@ name = "gl-examples" version = "0.1.0" edition = "2021" +publish = false # an example, not a library [dependencies] gl-client = { path = "../../libs/gl-client" } diff --git a/libs/uniffi-bindgen/Cargo.toml b/libs/uniffi-bindgen/Cargo.toml index 0df97517d..73a8bbb7f 100644 --- a/libs/uniffi-bindgen/Cargo.toml +++ b/libs/uniffi-bindgen/Cargo.toml @@ -2,6 +2,7 @@ name = "uniffi-bindgen" version = "0.1.0" edition = "2024" +publish = false # build tool; crates.io's uniffi-bindgen is a different crate [[bin]] # This can be whatever name makes sense for your project, but the rest of this tutorial assumes uniffi-bindgen. From 22e3a30e983eaa2cdd0789f0343530633a427e37 Mon Sep 17 00:00:00 2001 From: cdecker Date: Thu, 19 Nov 2026 13:59:30 +0100 Subject: [PATCH 12/20] ci: Publish the crates from a reusable workflow with a dry run publish-crates.yml takes the crates to release, in dependency order, and runs the checks of the tag-triggered release.yml on all of them: changelog, semver, tests. It then runs one multi-package cargo publish, which in a dry run packages each crate and builds it against the others' packages through a local registry overlay, so the dry run passes before any of them is on crates.io. The old dry run never ran cargo publish at all. A real run skips versions crates.io already has, uploads the rest and creates a -vX.Y.Z GitHub release for each. --- .github/workflows/publish-crates.yml | 153 +++++++++++++++++++++++++++ 1 file changed, 153 insertions(+) create mode 100644 .github/workflows/publish-crates.yml diff --git a/.github/workflows/publish-crates.yml b/.github/workflows/publish-crates.yml new file mode 100644 index 000000000..e09fc0d8b --- /dev/null +++ b/.github/workflows/publish-crates.yml @@ -0,0 +1,153 @@ +# Publishes workspace crates to crates.io. Called by release.yml, which +# passes the crates in dependency order. +# +# crates.io never deletes a version, it can only be yanked, so every crate +# passes these checks first, in a dry run too: +# +# 1. a Keep a Changelog CHANGELOG.md with an entry for the version +# 2. cargo-semver-checks against the latest published version, unless +# the bump allows breaking changes (X.0.0, or 0.X.0 before 1.0) +# 3. its tests +# 4. `cargo publish --dry-run` for all of them together +# +# Step 4 packages each crate and builds it against the others' packages. +# Cargo overlays the unpublished ones as a local registry, so a dry run +# passes before any of them is on crates.io. A real run uploads in that +# order, skips versions crates.io already has, and creates a +# `-vX.Y.Z` GitHub release for each crate. + +name: Crates + +on: + workflow_call: + inputs: + crates: + description: 'Space-separated crates, in dependency order' + required: true + type: string + dry_run: + required: true + type: boolean + +permissions: + contents: write + +jobs: + publish: + runs-on: ubuntu-latest + env: + CRATES: ${{ inputs.crates }} + steps: + - uses: actions/checkout@v4 + with: + # cargo-semver-checks compares against the published versions. + fetch-depth: 0 + + - uses: dtolnay/rust-toolchain@stable + + - name: Install Protoc + uses: arduino/setup-protoc@v3 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + + - uses: actions/setup-python@v5 + with: + python-version: '3.x' + + - name: Install python-kacl + run: pip install python-kacl + + - uses: cargo-bins/cargo-binstall@main + - run: cargo binstall --no-confirm cargo-semver-checks + + - name: Check the changelogs + run: | + META=$(cargo metadata --no-deps --format-version 1) + for CRATE in $CRATES; do + PKG=$(jq -c --arg c "$CRATE" '.packages[] | select(.name == $c)' <<<"$META") + VERSION=$(jq -r .version <<<"$PKG") + DIR=$(dirname "$(jq -r .manifest_path <<<"$PKG")") + if [ ! -f "$DIR/CHANGELOG.md" ]; then + echo "::error::$CRATE has no CHANGELOG.md in $DIR" + exit 1 + fi + # kacl-cli reads CHANGELOG.md from the working directory. + if ! (cd "$DIR" && kacl-cli verify --json) > kacl.json 2>&1; then + echo "::error::$DIR/CHANGELOG.md does not follow Keep a Changelog" + jq -r '.errors[] | "Line \(.line_number): \(.error_message)\n \(.line)"' kacl.json || cat kacl.json + exit 1 + fi + if ! grep -qE "^##? \[?v?${VERSION//./\\.}\]?" "$DIR/CHANGELOG.md"; then + echo "::error::$DIR/CHANGELOG.md has no entry for $CRATE $VERSION" + exit 1 + fi + echo "$CRATE $VERSION: changelog ok" + done + + - name: Check semver compatibility + run: | + META=$(cargo metadata --no-deps --format-version 1) + for CRATE in $CRATES; do + VERSION=$(jq -r --arg c "$CRATE" '.packages[] | select(.name == $c) | .version' <<<"$META") + IFS=. read -r MAJOR MINOR PATCH <<<"$VERSION" + if ! cargo info "$CRATE" --registry crates-io >/dev/null 2>&1; then + echo "$CRATE: not on crates.io yet, nothing to compare against" + elif [ "$MAJOR" != 0 ] && [ "$MINOR.$PATCH" = 0.0 ]; then + echo "$CRATE $VERSION: major bump, breaking changes allowed" + elif [ "$MAJOR" = 0 ] && [ "$PATCH" = 0 ]; then + echo "$CRATE $VERSION: 0.x minor bump, breaking changes allowed" + elif ! cargo semver-checks check-release -p "$CRATE"; then + echo "::error::$CRATE $VERSION breaks the API of its last release, bump the version accordingly" + exit 1 + fi + done + + - name: Run the tests + run: | + ARGS=() + for CRATE in $CRATES; do ARGS+=(-p "$CRATE"); done + cargo test "${ARGS[@]}" + + - name: Publish + env: + CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }} + DRY_RUN: ${{ inputs.dry_run }} + run: | + ARGS=() + META=$(cargo metadata --no-deps --format-version 1) + for CRATE in $CRATES; do + VERSION=$(jq -r --arg c "$CRATE" '.packages[] | select(.name == $c) | .version' <<<"$META") + if [ "$DRY_RUN" != true ] && cargo info "$CRATE@$VERSION" --registry crates-io >/dev/null 2>&1; then + echo "::notice::$CRATE $VERSION is already on crates.io, skipping it" + continue + fi + ARGS+=(-p "$CRATE") + done + if [ ${#ARGS[@]} = 0 ]; then + echo "Nothing to publish" + elif [ "$DRY_RUN" = true ]; then + cargo publish --dry-run "${ARGS[@]}" + else + cargo publish "${ARGS[@]}" + fi + + - name: Create the GitHub releases + if: ${{ !inputs.dry_run }} + env: + GH_TOKEN: ${{ github.token }} + run: | + META=$(cargo metadata --no-deps --format-version 1) + for CRATE in $CRATES; do + VERSION=$(jq -r --arg c "$CRATE" '.packages[] | select(.name == $c) | .version' <<<"$META") + TAG="$CRATE-v$VERSION" + DIR=$(dirname "$(jq -r --arg c "$CRATE" '.packages[] | select(.name == $c) | .manifest_path' <<<"$META")") + if gh release view "$TAG" >/dev/null 2>&1; then + echo "$TAG: release exists" + continue + fi + # swift.yml may create gl-sdk-vX.Y.Z concurrently, losing the + # race is fine. + gh release create "$TAG" --target "$GITHUB_SHA" --title "$CRATE v$VERSION" \ + --notes "Published $CRATE $VERSION to [crates.io](https://crates.io/crates/$CRATE/$VERSION). See the [changelog](https://github.com/$GITHUB_REPOSITORY/blob/$TAG/${DIR#"$GITHUB_WORKSPACE"/}/CHANGELOG.md)." \ + || gh release view "$TAG" >/dev/null + done From 9b12e70dcb7d74fed5a4e85dc859e9c5c9e9d9d6 Mon Sep 17 00:00:00 2001 From: cdecker Date: Thu, 19 Nov 2026 13:59:30 +0100 Subject: [PATCH 13/20] ci: Publish to PyPI only when the release workflow calls for it python.yml no longer publishes on gl-client-py-v* and gl-sdk-v* tags. release.yml calls it with the packages to publish and a dry-run flag. Both modes check that each file carries the version from pyproject.toml and that twine accepts the metadata. The dry run stops there, outside the pypi environment, so it needs no approval. The concurrency group names the workflow itself: a called workflow sees the caller's github.workflow, and the workflows release.yml calls would share a group and cancel each other. --- .github/scripts/check-dist.sh | 17 +++++ .github/workflows/python.yml | 119 +++++++++++++++++++++++----------- 2 files changed, 97 insertions(+), 39 deletions(-) create mode 100755 .github/scripts/check-dist.sh diff --git a/.github/scripts/check-dist.sh b/.github/scripts/check-dist.sh new file mode 100755 index 000000000..a59809513 --- /dev/null +++ b/.github/scripts/check-dist.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +# Checks the files about to go to PyPI: each one carries the expected +# version, and twine accepts the metadata. Used by python.yml in dry runs +# and real releases alike. +# +# check-dist.sh +set -euo pipefail +NAME=$1 VERSION=$2 DIR=$3 +ls -la "$DIR" +[ -n "$(ls -A "$DIR")" ] || { echo "::error::No files in $DIR"; exit 1; } +for f in "$DIR"/*; do + case "$(basename "$f")" in + "$NAME-$VERSION"-*.whl | "$NAME-$VERSION".tar.gz) ;; + *) echo "::error::$(basename "$f") is not $NAME $VERSION"; exit 1 ;; + esac +done +pipx run twine check --strict "$DIR"/* diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index f24b070ee..66b4b693b 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -4,22 +4,35 @@ on: push: branches: - main - # Release tags. `gl-client-py-vX.Y.Z` publishes the `gl-client` - # package and `gl-sdk-vX.Y.Z` the `gl-sdk` package to PyPI, see the - # publish jobs at the end. `gl-sdk-v*` also publishes the gl-sdk crate - # through release.yml. - tags: - - 'gl-client-py-v[0-9]+.[0-9]+.[0-9]+' - - 'gl-sdk-v[0-9]+.[0-9]+.[0-9]+' pull_request: types: - synchronize - opened workflow_dispatch: - + # Publishing runs only when release.yml calls this workflow. + workflow_call: + inputs: + release: + type: boolean + default: false + dry_run: + type: boolean + default: true + gl_client: + description: 'Publish the gl-client package' + type: boolean + default: false + gl_sdk: + description: 'Publish the gl-sdk package' + type: boolean + default: false + +# A called workflow sees the caller's github.workflow, so the group names +# this workflow itself, or it would share the group with the other +# workflows release.yml calls. concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true + group: python-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} jobs: source: @@ -323,41 +336,79 @@ jobs: # Publishing uses PyPI trusted publishing: PyPI accepts the GitHub OIDC # token of this workflow in the `pypi` environment, no API token needed. + # The token names the workflow that started the run, release.yml, so + # that is the workflow each PyPI trusted publisher has to name. + # + # A dry run checks the same files and stops before the upload, without + # the `pypi` environment, so it needs no approval. + check-gl-client: + name: Check gl-client for PyPI + if: inputs.release && inputs.gl_client + needs: [source, linux, macos, windows] + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4 + - uses: actions/download-artifact@v4 + with: + pattern: wheels-* + path: dist + merge-multiple: true + - name: Check the version and metadata + run: .github/scripts/check-dist.sh gl_client "$(sed -n 's/^version = "\(.*\)"/\1/p' libs/gl-client-py/pyproject.toml)" dist + publish-gl-client: name: Publish gl-client to PyPI - if: startsWith(github.ref, 'refs/tags/gl-client-py-v') - needs: [source, linux, macos, windows] + if: inputs.release && inputs.gl_client && !inputs.dry_run + needs: [check-gl-client] runs-on: ubuntu-24.04 environment: name: pypi url: https://pypi.org/project/gl-client/ permissions: - contents: read + contents: write id-token: write steps: + - uses: actions/checkout@v4 - uses: actions/download-artifact@v4 with: pattern: wheels-* path: dist merge-multiple: true - - - name: Check the version matches the tag - run: | - VERSION=${GITHUB_REF_NAME#gl-client-py-v} - ls -la dist - for f in dist/*; do - case "$(basename "$f")" in - gl_client-"$VERSION"-*.whl|gl_client-"$VERSION".tar.gz) ;; - *) echo "::error::$f does not match version $VERSION from the tag"; exit 1 ;; - esac - done - - uses: pypa/gh-action-pypi-publish@release/v1 + with: + # A re-run after a partial upload. + skip-existing: true + - name: Create the GitHub release + env: + GH_TOKEN: ${{ github.token }} + run: | + VERSION=$(sed -n 's/^version = "\(.*\)"/\1/p' libs/gl-client-py/pyproject.toml) + TAG="gl-client-py-v$VERSION" + gh release view "$TAG" >/dev/null 2>&1 || gh release create "$TAG" --target "$GITHUB_SHA" \ + --title "gl-client (Python) v$VERSION" \ + --notes "Published gl-client $VERSION to [PyPI](https://pypi.org/project/gl-client/$VERSION/). See the [changelog](https://github.com/$GITHUB_REPOSITORY/blob/$TAG/libs/gl-client-py/CHANGELOG.md)." + + check-gl-sdk: + name: Check gl-sdk for PyPI + if: inputs.release && inputs.gl_sdk + needs: [gl-sdk-wheels] + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4 + - uses: actions/download-artifact@v4 + with: + pattern: gl-sdk-wheel-* + path: dist + merge-multiple: true + - name: Check the version and metadata + run: .github/scripts/check-dist.sh gl_sdk "$(sed -n 's/^version = "\(.*\)"/\1/p' libs/gl-sdk/pyproject.toml)" dist + # The gl-sdk-vX.Y.Z GitHub release comes from the crate, in + # publish-crates.yml. publish-gl-sdk: name: Publish gl-sdk to PyPI - if: startsWith(github.ref, 'refs/tags/gl-sdk-v') - needs: [gl-sdk-wheels] + if: inputs.release && inputs.gl_sdk && !inputs.dry_run + needs: [check-gl-sdk] runs-on: ubuntu-24.04 environment: name: pypi @@ -371,16 +422,6 @@ jobs: pattern: gl-sdk-wheel-* path: dist merge-multiple: true - - - name: Check the version matches the tag - run: | - VERSION=${GITHUB_REF_NAME#gl-sdk-v} - ls -la dist - for f in dist/*; do - case "$(basename "$f")" in - gl_sdk-"$VERSION"-*.whl) ;; - *) echo "::error::$f does not match version $VERSION from the tag"; exit 1 ;; - esac - done - - uses: pypa/gh-action-pypi-publish@release/v1 + with: + skip-existing: true From 65128e3d356c9ffa462b05b744895e63f2135b4b Mon Sep 17 00:00:00 2001 From: cdecker Date: Thu, 19 Nov 2026 13:59:30 +0100 Subject: [PATCH 14/20] ci: Publish npm only when the release workflow calls for it typescript.yml published on every push to main whose version npm did not have yet. It now always builds and tests, and publishes only when release.yml calls it, or runs `npm publish --dry-run` for a dry run. --- .github/workflows/typescript.yml | 35 ++++++++++++++++---------------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/.github/workflows/typescript.yml b/.github/workflows/typescript.yml index cc61ebd04..18b6e9cb3 100644 --- a/.github/workflows/typescript.yml +++ b/.github/workflows/typescript.yml @@ -7,20 +7,23 @@ on: - main pull_request: {} workflow_dispatch: + # Publishing runs only when release.yml calls this workflow. + workflow_call: inputs: - shouldPublish: - description: 'Publish to NPM' + release: + type: boolean + default: false + dry_run: type: boolean default: true name: Typescript Library jobs: - # Build, test and publish only when the version in package.json is not - # on npm yet. Comparing against the registry rather than against the - # parent commit keeps this correct for rebase-merges, where the version - # bump is not the tip commit, and lets a re-run publish a version that - # an earlier run failed to publish. + # Whether the version in package.json is on npm yet. Comparing against + # the registry rather than against the parent commit stays correct for + # rebase-merges, where the version bump is not the tip commit, and lets + # a re-run publish a version that an earlier run failed to publish. check-version: runs-on: ubuntu-latest outputs: @@ -42,13 +45,11 @@ jobs: echo "${NAME}@${VERSION} is not on npm yet" echo "unpublished=true" >> $GITHUB_OUTPUT else - echo "::notice::${NAME}@${VERSION} is already on npm, skipping build and publish" + echo "${NAME}@${VERSION} is already on npm" echo "unpublished=false" >> $GITHUB_OUTPUT fi build: - needs: check-version - if: needs.check-version.outputs.unpublished == 'true' strategy: fail-fast: false matrix: @@ -241,11 +242,13 @@ jobs: shell: bash command: cd libs/gl-sdk-napi && npm test -- tests/basic.spec.ts + # A dry run packs and checks the package like a release and stops before + # the upload. It also runs for a version npm already has. publish: name: Publish to NPM runs-on: ubuntu-latest - needs: test - if: (github.event_name == 'push' && github.ref == 'refs/heads/main') || (github.event_name == 'workflow_dispatch' && inputs.shouldPublish == true) + needs: [check-version, test] + if: inputs.release && (inputs.dry_run || needs.check-version.outputs.unpublished == 'true') defaults: run: @@ -266,6 +269,7 @@ jobs: - name: Download all artifacts uses: actions/download-artifact@v4 with: + pattern: bindings-* path: artifacts - name: Move artifacts to package directory @@ -278,12 +282,7 @@ jobs: done ls -la *.* - - name: List package contents - run: npm pack --dry-run - - name: Publish to NPM - run: | - echo "Token length: ${#NODE_AUTH_TOKEN}" - npm publish --access public + run: npm publish --access public ${{ inputs.dry_run && '--dry-run' || '' }} env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} From c1dd538d1dc322156acf189f1bc021671ae9d98c Mon Sep 17 00:00:00 2001 From: cdecker Date: Thu, 19 Nov 2026 13:59:30 +0100 Subject: [PATCH 15/20] ci: Check the Swift package with gl-sdk-swift's publish scripts Every Swift build checks out gl-sdk-swift's main and runs its scripts/prepare.sh and scripts/check-package.sh against the fresh XCFramework, instead of an inline copy of its Package.swift. A template change there that does not fit the build fails here first. A real release, called from release.yml, attaches the assets to the gl-sdk-vX.Y.Z release, waits for gl-sdk-swift to tag X.Y.Z and verifies it with scripts/verify.sh, so the Swift release shows on this repository's Actions page. --- .github/workflows/swift.yml | 163 +++++++++++++++++++++++------------- 1 file changed, 104 insertions(+), 59 deletions(-) diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml index f0de8dfd7..df7767c2f 100644 --- a/.github/workflows/swift.yml +++ b/.github/workflows/swift.yml @@ -1,11 +1,18 @@ name: Swift -# Builds the gl-sdk XCFramework and Swift bindings. On a gl-sdk-vX.Y.Z -# tag they are attached to this repository's gl-sdk-vX.Y.Z release, where -# Blockstream/gl-sdk-swift picks them up: its publish workflow commits the -# bindings and a Package.swift pointing at the zip here, and tags X.Y.Z. -# Each repository only writes to itself, so no cross-repository token is -# needed. +# Builds the gl-sdk XCFramework and Swift bindings, and checks them with +# Blockstream/gl-sdk-swift's own publish scripts from its main branch: +# scripts/prepare.sh renders Package.swift for the build and commits and +# tags it locally, scripts/check-package.sh compiles that package against +# the fresh XCFramework. Nothing leaves the runner, so every build is a +# dry run of the Swift release. +# +# When release.yml calls it for a real release, it also attaches the zip, +# its checksum and glsdk.swift to the gl-sdk-vX.Y.Z release here, where +# gl-sdk-swift's hourly publish.yml picks them up. It then waits for the +# X.Y.Z tag in gl-sdk-swift and verifies it the way SwiftPM installs it, +# so the outcome shows on this repository's Actions page. Neither +# repository writes to the other, so no cross-repository token is needed. on: push: @@ -18,8 +25,6 @@ on: - 'libs/gl-sdk/**' - 'libs/proto/**' - 'Cargo.lock' - tags: - - 'gl-sdk-v[0-9]+.[0-9]+.[0-9]+' pull_request: paths: - '.github/workflows/swift.yml' @@ -29,18 +34,35 @@ on: - 'libs/proto/**' - 'Cargo.lock' workflow_dispatch: - + # Publishing runs only when release.yml calls this workflow. + workflow_call: + inputs: + release: + type: boolean + default: false + dry_run: + type: boolean + default: true + +# A called workflow sees the caller's github.workflow, so the group names +# this workflow itself, or it would share the group with the other +# workflows release.yml calls. concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true + group: swift-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} permissions: contents: read +env: + SWIFT_REPO: Blockstream/gl-sdk-swift + jobs: build: name: Build XCFramework runs-on: macos-15 + outputs: + version: ${{ steps.version.outputs.version }} steps: - uses: actions/checkout@v4 @@ -49,14 +71,12 @@ jobs: targets: aarch64-apple-ios,aarch64-apple-ios-sim,x86_64-apple-ios - name: Determine the version + id: version run: | - if [[ "$GITHUB_REF" == refs/tags/gl-sdk-v* ]]; then - VERSION="${GITHUB_REF_NAME#gl-sdk-v}" - else - VERSION=$(cargo metadata --no-deps --format-version 1 | \ - jq -r '.packages[] | select(.name == "gl-sdk") | .version') - fi + VERSION=$(cargo metadata --no-deps --format-version 1 | \ + jq -r '.packages[] | select(.name == "gl-sdk") | .version') echo "VERSION=$VERSION" >> "$GITHUB_ENV" + echo "version=$VERSION" >> "$GITHUB_OUTPUT" echo "Building gl-sdk $VERSION" - uses: Swatinem/rust-cache@v2 @@ -89,46 +109,36 @@ jobs: cp target/swift/glsdk.swift dist/glsdk.swift # SwiftPM verifies the zip against this checksum, the SHA-256. swift package compute-checksum dist/glsdkFFI.xcframework.zip > dist/glsdkFFI.xcframework.zip.checksum - shasum -a 256 dist/glsdkFFI.xcframework.zip - cat dist/glsdkFFI.xcframework.zip.checksum ls -la dist - # Compiles the bindings against the framework as a Swift package, - # the way gl-sdk-swift ships them, for the iOS simulator. - - name: Compile the Swift package + - uses: actions/checkout@v4 + with: + repository: ${{ env.SWIFT_REPO }} + ref: main + path: gl-sdk-swift + fetch-depth: 0 + + # What gl-sdk-swift's publish.yml does with these assets, short of + # pushing: render and commit Package.swift, tag the version, and + # compile the package against the zip. + - name: Prepare the Swift package + working-directory: gl-sdk-swift run: | - PKG="$RUNNER_TEMP/GreenlightSDK" - mkdir -p "$PKG/Sources/GreenlightSDK" - cp dist/glsdk.swift "$PKG/Sources/GreenlightSDK/GreenlightSDK.swift" - (cd "$PKG" && unzip -q "$GITHUB_WORKSPACE/dist/glsdkFFI.xcframework.zip") - cat > "$PKG/Package.swift" <<'EOF' - // swift-tools-version:5.5 - import PackageDescription - - let package = Package( - name: "glsdk", - platforms: [.macOS(.v12), .iOS(.v13)], - products: [ - .library(name: "GreenlightSDK", targets: ["glsdkFFI", "GreenlightSDK"]), - ], - targets: [ - .binaryTarget(name: "glsdkFFI", path: "glsdkFFI.xcframework"), - .target(name: "GreenlightSDK", dependencies: ["glsdkFFI"]), - ] - ) - EOF - cd "$PKG" - # Xcode derives the schemes from the package, list them and - # build the library product's, or the whole package's. - SCHEMES=$(xcodebuild -list -json | jq -r '(.workspace // .project).schemes[]') - echo "Schemes: $(echo $SCHEMES)" - SCHEME=$(grep -xE 'GreenlightSDK|glsdk-Package|glsdk' <<<"$SCHEMES" | head -n1) - if [ -z "$SCHEME" ]; then - echo "::error::No GreenlightSDK or glsdk scheme in the package" - exit 1 + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + # A version that is published already cannot be tagged again, + # prepare it as a pre-release of itself instead. + V="$VERSION" + if git rev-parse -q --verify "refs/tags/$V" >/dev/null; then + V="$VERSION-check.$GITHUB_RUN_NUMBER" + echo "::notice::$VERSION is published in gl-sdk-swift already, preparing it as $V" fi - xcodebuild build -scheme "$SCHEME" \ - -destination 'generic/platform=iOS Simulator' -quiet + scripts/prepare.sh "$V" "$GITHUB_WORKSPACE/dist" \ + "https://github.com/$GITHUB_REPOSITORY/releases/download/gl-sdk-v$VERSION/glsdkFFI.xcframework.zip" + cat Package.swift + + - name: Compile the Swift package + run: gl-sdk-swift/scripts/check-package.sh dist/glsdkFFI.xcframework.zip - uses: actions/upload-artifact@v4 with: @@ -136,11 +146,9 @@ jobs: path: dist/ if-no-files-found: error - # release.yml creates the gl-sdk-vX.Y.Z release once the crate is - # published. Whichever runs first creates it, the other updates it. attach: name: Attach to the gl-sdk release - if: startsWith(github.ref, 'refs/tags/gl-sdk-v') + if: inputs.release && !inputs.dry_run needs: build runs-on: ubuntu-latest permissions: @@ -148,22 +156,59 @@ jobs: env: GH_TOKEN: ${{ github.token }} GH_REPO: ${{ github.repository }} + TAG: gl-sdk-v${{ needs.build.outputs.version }} steps: - uses: actions/download-artifact@v4 with: name: swift path: dist + # publish-crates.yml creates the release when it publishes the gl-sdk + # crate. A Swift-only release creates it here. - name: Upload the release assets run: | - TAG="$GITHUB_REF_NAME" if ! gh release view "$TAG" >/dev/null 2>&1; then - gh release create "$TAG" --verify-tag --title "gl-sdk ${TAG#gl-sdk-v}" \ + gh release create "$TAG" --target "$GITHUB_SHA" --title "gl-sdk ${TAG#gl-sdk-v}" \ --notes "See the [gl-sdk changelog](https://github.com/$GH_REPO/blob/$TAG/libs/gl-sdk/CHANGELOG.md)." \ - || gh release view "$TAG" >/dev/null # lost the race to release.yml + || gh release view "$TAG" >/dev/null # created concurrently fi gh release upload "$TAG" --clobber \ dist/glsdkFFI.xcframework.zip \ dist/glsdkFFI.xcframework.zip.checksum \ dist/glsdk.swift gh release view "$TAG" --json assets --jq '.assets[].name' + + # gl-sdk-swift publishes within the hour, at 17 past, and GitHub can + # delay scheduled runs. Running its publish.yml by hand is quicker. + published: + name: Wait for gl-sdk-swift + needs: [build, attach] + runs-on: ubuntu-latest + timeout-minutes: 120 + env: + VERSION: ${{ needs.build.outputs.version }} + steps: + - uses: actions/checkout@v4 + with: + repository: ${{ env.SWIFT_REPO }} + ref: main + path: gl-sdk-swift + + - name: Wait for the tag + run: | + echo "::notice::Waiting for $VERSION in https://github.com/$SWIFT_REPO, run its publish.yml to skip the wait" + until git ls-remote --exit-code --tags "https://github.com/$SWIFT_REPO" "refs/tags/$VERSION" >/dev/null; do + sleep 120 + done + + - name: Verify the package + run: | + gl-sdk-swift/scripts/verify.sh "$VERSION" + # The package must download the zip attached by this run. + URL=$(curl -fsSL "https://raw.githubusercontent.com/$SWIFT_REPO/refs/tags/$VERSION/Package.swift" \ + | sed -nE 's/.*url: "([^"]+)".*/\1/p') + WANT="https://github.com/$GITHUB_REPOSITORY/releases/download/gl-sdk-v$VERSION/glsdkFFI.xcframework.zip" + if [ "$URL" != "$WANT" ]; then + echo "::error::Package.swift at $VERSION downloads $URL, not $WANT" + exit 1 + fi From 8fd67e5875de950dc455523ecca070c530c646f6 Mon Sep 17 00:00:00 2001 From: cdecker Date: Thu, 19 Nov 2026 13:59:30 +0100 Subject: [PATCH 16/20] ci: Release every artifact from one dispatched workflow Actions > Release > Run workflow now releases the crates, both Python packages, npm, Swift and Maven, replacing the per-crate tag trigger. Its plan step reads each version from the repository, asks the registry whether it is published and writes the plan to the run summary. A real release, from main only, publishes what is missing, crates first, then the bindings in parallel. A dry run, the default, exercises every selected artifact up to the upload, from any branch. The plan also fails on wildcard dependency requirements, which crates.io only rejects on upload, and on bindings whose versions disagree. --- .github/scripts/release_plan.py | 190 +++++++++ .github/workflows/release.yml | 697 ++++++-------------------------- 2 files changed, 324 insertions(+), 563 deletions(-) create mode 100755 .github/scripts/release_plan.py diff --git a/.github/scripts/release_plan.py b/.github/scripts/release_plan.py new file mode 100755 index 000000000..096f00cb4 --- /dev/null +++ b/.github/scripts/release_plan.py @@ -0,0 +1,190 @@ +#!/usr/bin/env python3 +"""Work out what a release publishes, for .github/workflows/release.yml. + +Reads every artifact's version from the repository and asks its registry +whether that version is published. A real release publishes only what is +missing. A dry run exercises every selected artifact, published or not, +so it can run at any time. + +Also fails on mistakes that only the registries would catch otherwise: +wildcard dependency requirements, which crates.io rejects on upload, and +artifacts that must share a version but don't. + +Runs locally too, it only needs cargo and network access: + + python3 .github/scripts/release_plan.py --dry-run + +On GitHub it writes its decisions to $GITHUB_OUTPUT and a table to +$GITHUB_STEP_SUMMARY. +""" + +import argparse +import json +import os +import subprocess +import sys +import tomllib +import urllib.error +import urllib.request +from pathlib import Path + +ROOT = Path(__file__).resolve().parents[2] +SWIFT_REPO = "https://github.com/Blockstream/gl-sdk-swift" +USER_AGENT = "greenlight-release-plan (https://github.com/Blockstream/greenlight)" +GROUPS = ("crates", "python", "npm", "swift", "maven") + + +def published(url: str) -> bool: + """True on 200, False on 404, an error for anything else.""" + req = urllib.request.Request(url, headers={"User-Agent": USER_AGENT}) + try: + with urllib.request.urlopen(req, timeout=30): + return True + except urllib.error.HTTPError as e: + if e.code == 404: + return False + raise SystemExit(f"error: {url} answered {e.code}, cannot tell whether it is published") + + +def swift_tag_exists(version: str) -> bool: + out = subprocess.run( + ["git", "ls-remote", "--tags", SWIFT_REPO, f"refs/tags/{version}"], + check=True, capture_output=True, text=True, + ).stdout + return bool(out.strip()) + + +def pyproject_version(path: str) -> str: + with open(ROOT / path, "rb") as f: + return tomllib.load(f)["project"]["version"] + + +def gradle_property(path: str, key: str) -> str: + for line in (ROOT / path).read_text().splitlines(): + k, _, v = line.partition("=") + if k.strip() == key: + return v.strip() + raise SystemExit(f"error: no {key} in {path}") + + +def publish_order(packages: dict) -> list: + """Workspace crates ordered so each comes after its workspace dependencies.""" + deps = { + name: { + d["name"] for d in pkg["dependencies"] + if d["name"] in packages and d["kind"] != "dev" + } + for name, pkg in packages.items() + } + order, done = [], set() + while len(order) < len(packages): + ready = sorted(n for n in packages if n not in done and deps[n] <= done) + if not ready: + raise SystemExit(f"error: dependency cycle among {sorted(set(packages) - done)}") + order += ready + done |= set(ready) + return order + + +def main() -> None: + ap = argparse.ArgumentParser(description=__doc__.splitlines()[0]) + ap.add_argument("--dry-run", action="store_true") + ap.add_argument("--select", default=",".join(GROUPS), + help=f"comma-separated subset of {','.join(GROUPS)}") + args = ap.parse_args() + selected = {g for g in args.select.split(",") if g} + if selected - set(GROUPS): + raise SystemExit(f"error: unknown group(s) {sorted(selected - set(GROUPS))}") + + meta = json.loads(subprocess.run( + ["cargo", "metadata", "--no-deps", "--format-version", "1"], + cwd=ROOT, check=True, capture_output=True, text=True, + ).stdout) + workspace = {p["name"]: p for p in meta["packages"]} + crates = {n: p for n, p in workspace.items() if p["publish"] != []} + + errors = [] + rows = [] # (group, artifact, version, registry, published, action) + + def decide(group, artifact, version, registry, is_published): + if group not in selected: + action = "not selected" + elif is_published: + action = "dry run (already published)" if args.dry_run else "skip, already published" + else: + action = "dry run" if args.dry_run else "publish" + rows.append((group, artifact, version, registry, is_published, action)) + return group in selected and (args.dry_run or not is_published) + + # crates.io rejects wildcard requirements only on upload. + for name, pkg in crates.items(): + for d in pkg["dependencies"]: + if d["req"] == "*" and d["kind"] != "dev": + errors.append(f'{name}: dependency `{d["name"]} = "*"`, crates.io rejects wildcard requirements') + + crate_list = [] + for name in publish_order(crates): + v = crates[name]["version"] + if decide("crates", name, v, "crates.io", + published(f"https://crates.io/api/v1/crates/{name}/{v}")): + crate_list.append(name) + + sdk = workspace["gl-sdk"]["version"] + gl_client_py = pyproject_version("libs/gl-client-py/pyproject.toml") + gl_sdk_py = pyproject_version("libs/gl-sdk/pyproject.toml") + package_json = json.loads((ROOT / "libs/gl-sdk-napi/package.json").read_text()) + maven = gradle_property("libs/gl-sdk-android/gradle.properties", "libraryVersion") + + # The bindings of one SDK release share the gl-sdk version, and each + # binding's crate carries the version of the package built from it. + for what, version, want in [ + ("libs/gl-sdk/pyproject.toml", gl_sdk_py, sdk), + ("libraryVersion in libs/gl-sdk-android/gradle.properties", maven, sdk), + ("libs/gl-client-py/pyproject.toml", gl_client_py, workspace["gl-client-py"]["version"]), + ("libs/gl-sdk-napi/package.json", package_json["version"], workspace["gl-sdk-node"]["version"]), + ]: + if version != want: + errors.append(f"{what} says {version}, expected {want}") + + out = { + "crates": " ".join(crate_list), + "gl_client_py": decide("python", "gl-client (PyPI)", gl_client_py, "PyPI", + published(f"https://pypi.org/pypi/gl-client/{gl_client_py}/json")), + "gl_sdk_py": decide("python", "gl-sdk (PyPI)", gl_sdk_py, "PyPI", + published(f"https://pypi.org/pypi/gl-sdk/{gl_sdk_py}/json")), + } + npm_name, npm_version = package_json["name"], package_json["version"] + npm_doc = f"https://registry.npmjs.org/{npm_name.replace('/', '%2F')}/{npm_version}" + out["npm"] = decide("npm", npm_name, npm_version, "npm", published(npm_doc)) + out["swift"] = decide("swift", "GreenlightSDK", sdk, "gl-sdk-swift tag", swift_tag_exists(sdk)) + out["maven"] = decide("maven", "com.blockstream:glsdk", maven, "Maven Central", published( + f"https://repo1.maven.org/maven2/com/blockstream/glsdk/{maven}/glsdk-{maven}.pom")) + out["sdk_version"] = sdk + + mode = "Dry run" if args.dry_run else "Release" + summary = [f"## {mode} plan", "", "| Group | Artifact | Version | Registry | Published | Action |", + "| --- | --- | --- | --- | --- | --- |"] + summary += [f"| {g} | `{a}` | {v} | {r} | {'yes' if p else 'no'} | {act} |" + for g, a, v, r, p, act in rows] + if errors: + summary += ["", "### Errors", ""] + [f"- {e}" for e in errors] + text = "\n".join(summary) + "\n" + print(text) + if path := os.environ.get("GITHUB_STEP_SUMMARY"): + with open(path, "a") as f: + f.write(text) + if path := os.environ.get("GITHUB_OUTPUT"): + with open(path, "a") as f: + for k, v in out.items(): + f.write(f"{k}={str(v).lower() if isinstance(v, bool) else v}\n") + else: + print(json.dumps(out, indent=2)) + + for e in errors: + print(f"::error::{e}" if os.environ.get("GITHUB_ACTIONS") else f"error: {e}", file=sys.stderr) + if errors: + sys.exit(1) + + +if __name__ == "__main__": + main() diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 18717e5bf..f8e10d556 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,584 +1,155 @@ -# ============================================================================== -# CRATE PUBLISHING WORKFLOW -# ============================================================================== -# Purpose: Automatically publish Rust crates from a monorepo to crates.io +# The one place to release the SDK: Actions > Release > Run workflow. # -# Trigger: Push a git tag matching the pattern `-v` -# Example: `mycrate-v1.2.3` +# Each artifact's version comes from the repository. The plan job asks the +# registries which of them are published, and a release publishes the +# rest. A dry run (the default) builds, tests and packages every selected +# artifact, published or not, and stops before each upload, so it can run +# at any time, from any branch. Real releases run from main only. # -# Safety Philosophy: This workflow implements multiple validation gates to catch -# issues before publishing. Once a crate version is published to crates.io, it -# cannot be unpublished (only yanked), so we want to ensure everything is correct. +# crates gl-client, gl-util, gl-plugin, gl-signerproxy, gl-cli, gl-sdk, +# gl-sdk-cli to crates.io publish-crates.yml +# python gl-client and gl-sdk to PyPI python.yml +# npm @greenlightcln/glsdk to npm typescript.yml +# swift GreenlightSDK, through Blockstream/gl-sdk-swift swift.yml +# maven com.blockstream:glsdk to Maven Central kotlin.yml # -# Workflow Steps: -# 1. Version Match - Ensures Cargo.toml version matches the tag -# 2. Changelog Format - Validates changelog follows Keep a Changelog format -# 3. Changelog Entry - Ensures this version is documented in changelog -# 4. Semver Check - Prevents accidental breaking changes in minor/patch bumps -# 5. Tests - Runs the crate's test suite -# 6. Publish - Publishes to crates.io and creates GitHub release -# -# These checks should have already passed in CI (on PRs/main branch), but we -# run them again here as a final safety gate before the irreversible publish. -# ============================================================================== +# The crates go first, then the bindings in parallel, so a binding never +# ships a gl-sdk version whose crates failed to publish. Every step skips +# what its registry already has, so re-running a partly failed release +# publishes what is missing. -name: Publish Crate +name: Release on: - push: - tags: - # Matches tags like: mycrate-v1.2.3, my-crate-v0.1.0, etc. - # The 'v' prefix helps distinguish version tags from other tags - - '*-v[0-9]+.[0-9]+.[0-9]+' - - # Manual trigger for dry-run testing - # This allows testing all validation checks without actually publishing workflow_dispatch: inputs: - crate: - description: 'Crate name to test (e.g., gl-client)' - required: true - type: string - version: - description: 'Version to test (e.g., 1.2.3)' - required: true - type: string + dry_run: + description: 'Dry run: build and check everything, publish nothing' + type: boolean + default: true + crates: + description: 'Rust crates (crates.io)' + type: boolean + default: true + python: + description: 'gl-client and gl-sdk (PyPI)' + type: boolean + default: true + npm: + description: '@greenlightcln/glsdk (npm)' + type: boolean + default: true + swift: + description: 'GreenlightSDK (gl-sdk-swift)' + type: boolean + default: true + maven: + description: 'com.blockstream:glsdk (Maven Central)' + type: boolean + default: true + +concurrency: + group: release + cancel-in-progress: false permissions: - contents: write + contents: read + +run-name: ${{ inputs.dry_run && 'Release dry run' || 'Release' }} from ${{ github.ref_name }} jobs: - # Some tags matching the pattern above release a package that is not a - # crate, for example `gl-client-py-v*` publishes the Python package from - # python.yml. Their workspace crate sets `publish = false`, and this job - # skips them. A tag naming no workspace crate at all still runs the - # publish job, which fails on it. - filter: + plan: runs-on: ubuntu-latest outputs: - publish: ${{ steps.filter.outputs.publish }} + crates: ${{ steps.plan.outputs.crates }} + gl_client_py: ${{ steps.plan.outputs.gl_client_py }} + gl_sdk_py: ${{ steps.plan.outputs.gl_sdk_py }} + npm: ${{ steps.plan.outputs.npm }} + swift: ${{ steps.plan.outputs.swift }} + maven: ${{ steps.plan.outputs.maven }} steps: - - uses: actions/checkout@v4 - - - id: filter + - name: Real releases run from main + if: ${{ !inputs.dry_run && github.ref != 'refs/heads/main' }} run: | - if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then - CRATE="${{ inputs.crate }}" - else - CRATE=$(echo "${GITHUB_REF#refs/tags/}" | sed -E 's/-v[0-9]+\.[0-9]+\.[0-9]+$//') - fi - # `publish = false` shows as an empty registry list. - PUBLISH=$(cargo metadata --no-deps --format-version 1 | \ - jq -r --arg c "$CRATE" '.packages[] | select(.name == $c) | if .publish == [] then "false" else "true" end') - if [ "$PUBLISH" = "false" ]; then - echo "::notice::$CRATE sets publish = false, not publishing it to crates.io" - echo "publish=false" >> $GITHUB_OUTPUT - else - echo "publish=true" >> $GITHUB_OUTPUT - fi + echo "::error::Releasing from $GITHUB_REF, release from main or start a dry run" + exit 1 - publish: - needs: filter - if: needs.filter.outputs.publish == 'true' - runs-on: ubuntu-latest - steps: - # ========================================================================== - # SETUP: Checkout and Parse Tag - # ========================================================================== - - uses: actions/checkout@v4 - with: - # fetch-depth: 0 gets the full git history, which is required for - # cargo-semver-checks to compare against previous published versions - fetch-depth: 0 - - - name: Parse tag - id: parse - run: | - # Check if this is a manual dispatch (dry-run) or tag-triggered run - if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then - # Manual dispatch - use inputs - CRATE="${{ inputs.crate }}" - VERSION="${{ inputs.version }}" - echo "🧪 DRY-RUN MODE: Testing $CRATE version $VERSION" - echo "dry_run=true" >> $GITHUB_OUTPUT - else - # Tag-triggered - parse from tag - # Extract the full tag name from the GitHub ref - # GITHUB_REF format: refs/tags/mycrate-v1.2.3 - TAG=${GITHUB_REF#refs/tags/} - echo "Full tag: $TAG" - - # Parse the tag to extract crate name and version - # Example: mycrate-v1.2.3 → CRATE=mycrate, VERSION=1.2.3 - # This regex removes everything from '-v' onwards to get the crate name - CRATE=$(echo $TAG | sed -E 's/-v[0-9]+\.[0-9]+\.[0-9]+$//') - - # This regex extracts just the version numbers after '-v' - VERSION=$(echo $TAG | sed -E 's/.*-v([0-9]+\.[0-9]+\.[0-9]+)$/\1/') - - echo "📦 Publishing $CRATE version $VERSION" - echo "dry_run=false" >> $GITHUB_OUTPUT - fi - # Make these available to subsequent steps via GITHUB_OUTPUT - echo "crate=$CRATE" >> $GITHUB_OUTPUT - echo "version=$VERSION" >> $GITHUB_OUTPUT - - # Parse semantic version components for later use in semver checks - # We need to know if this is a major/minor/patch bump to determine - # whether breaking changes are allowed - MAJOR=$(echo $VERSION | cut -d. -f1) - MINOR=$(echo $VERSION | cut -d. -f2) - PATCH=$(echo $VERSION | cut -d. -f3) - - echo "major=$MAJOR" >> $GITHUB_OUTPUT - echo "minor=$MINOR" >> $GITHUB_OUTPUT - echo "patch=$PATCH" >> $GITHUB_OUTPUT - - - uses: dtolnay/rust-toolchain@stable - - - name: Install Protoc - uses: arduino/setup-protoc@v3 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - - # ========================================================================== - # CHECK 1: Version Match - # ========================================================================== - # Rationale: The tag version must match the version in Cargo.toml. - # This prevents accidentally publishing the wrong version or forgetting to - # bump the version in Cargo.toml before tagging. - # - # Why this matters: If we published with a mismatched version, the published - # crate would have a different version than expected, breaking consumer - # dependencies and causing confusion. - # ========================================================================== - - - name: Verify version matches - run: | - echo "🔍 CHECK 1/5: Verifying Cargo.toml version..." - - # Use cargo metadata to extract the version from Cargo.toml - # This is more reliable than parsing TOML manually - # The jq command filters packages by name and extracts the version field - CARGO_VERSION=$(cargo metadata --no-deps --format-version 1 | \ - jq -r '.packages[] | select(.name == "${{ steps.parse.outputs.crate }}") | .version') - - # Check if we found the crate in the workspace - if [ -z "$CARGO_VERSION" ]; then - echo "❌ ERROR: Crate '${{ steps.parse.outputs.crate }}' not found in workspace" - echo "" - echo "This usually means:" - echo " 1. The crate name in the tag doesn't match any crate in the workspace" - echo " 2. The crate is not included in the workspace members" - exit 1 - fi - - # Compare versions - if [ "$CARGO_VERSION" != "${{ steps.parse.outputs.version }}" ]; then - echo "❌ ERROR: Version mismatch!" - echo " Tag version: ${{ steps.parse.outputs.version }}" - echo " Cargo.toml version: $CARGO_VERSION" - echo "" - echo "Please update Cargo.toml to version ${{ steps.parse.outputs.version }}" - echo "and create a new tag, or delete this tag and create a new one matching" - echo "the Cargo.toml version." - exit 1 - fi - - echo "✅ Version verified: $CARGO_VERSION" - - # ========================================================================== - # CHECK 2: Changelog Format Validation - # ========================================================================== - # Rationale: Validates that the changelog follows the Keep a Changelog format. - # This ensures consistency and makes changelogs machine-readable. - # - # Why this matters: A properly formatted changelog is easier to parse - # programmatically, looks professional, and helps users quickly find - # information about specific versions. It also catches common formatting - # errors like missing dates, wrong heading levels, etc. - # - # Tool choice: python-kacl provides excellent error messages with line - # numbers and specific issues, making it easy to fix problems. - # ========================================================================== - - - name: Setup Python for changelog validation - uses: actions/setup-python@v5 - with: - python-version: '3.x' - - - name: Install python-kacl - run: pip install python-kacl - - - name: Validate changelog format + - id: plan run: | - echo "🔍 CHECK 2/5: Validating changelog format..." - - CRATE="${{ steps.parse.outputs.crate }}" - - # Find the crate's directory in the workspace - # We use cargo metadata rather than assuming a directory structure - CRATE_DIR=$(cargo metadata --no-deps --format-version 1 | \ - jq -r ".packages[] | select(.name == \"$CRATE\") | .manifest_path" | \ - xargs dirname) - - # Look for changelog files in order of preference - # We check multiple variants because conventions vary - CHANGELOG="" - for name in CHANGELOG.md changelog.md CHANGELOG; do - if [ -f "$CRATE_DIR/$name" ]; then - CHANGELOG="$CRATE_DIR/$name" - break - fi + SELECT="" + for G in crates python npm swift maven; do + case "$G" in + crates) ON=${{ inputs.crates }} ;; + python) ON=${{ inputs.python }} ;; + npm) ON=${{ inputs.npm }} ;; + swift) ON=${{ inputs.swift }} ;; + maven) ON=${{ inputs.maven }} ;; + esac + [ "$ON" = true ] && SELECT="$SELECT,$G" done - - if [ -z "$CHANGELOG" ]; then - echo "❌ ERROR: No changelog found in $CRATE_DIR" - echo "" - echo "Expected one of: CHANGELOG.md, changelog.md, CHANGELOG" - echo "Please create a changelog following the Keep a Changelog format:" - echo "https://keepachangelog.com/" - exit 1 - fi - - echo "Validating $CHANGELOG..." - - # Run kacl-cli verify with JSON output for structured error reporting - # The JSON output makes it easier to parse and display errors - # Note: kacl-cli reads CHANGELOG.md from cwd, does not accept file arguments - if (cd "$CRATE_DIR" && kacl-cli verify --json) > /tmp/kacl-output.json 2>&1; then - echo "✅ Changelog format is valid" - else - echo "❌ ERROR: Changelog format validation failed" - echo "" - echo "The following issues were found:" - echo "" - - # Parse and display errors in a human-readable format - cat /tmp/kacl-output.json | jq -r '.errors[] | "Line \(.line_number): \(.error_message)\n → \(.line)\n"' - - echo "" - echo "Please fix these issues and try again." - echo "See https://keepachangelog.com/ for format guidelines." - exit 1 - fi - - # ========================================================================== - # CHECK 3: Changelog Entry Exists - # ========================================================================== - # Rationale: Ensures that this specific version has been documented in the - # changelog before we publish it. - # - # Why this matters: Publishing without changelog documentation means users - # won't know what changed in this version. This is especially important for - # breaking changes or new features. It also enforces good release hygiene - # by ensuring documentation happens before release, not after. - # - # Note: This check is separate from format validation because a changelog - # can be properly formatted but missing the entry for the version being - # published (e.g., if someone forgot to move changes from Unreleased). - # ========================================================================== - - - name: Verify changelog entry exists - run: | - echo "🔍 CHECK 3/5: Checking for changelog entry..." - - CRATE="${{ steps.parse.outputs.crate }}" - VERSION="${{ steps.parse.outputs.version }}" - - # Find the changelog (same logic as CHECK 2) - CRATE_DIR=$(cargo metadata --no-deps --format-version 1 | \ - jq -r ".packages[] | select(.name == \"$CRATE\") | .manifest_path" | \ - xargs dirname) - - CHANGELOG="" - for name in CHANGELOG.md changelog.md CHANGELOG; do - if [ -f "$CRATE_DIR/$name" ]; then - CHANGELOG="$CRATE_DIR/$name" - break - fi - done - - # Search for version entry using regex that matches common formats: - # - ## [1.2.3] (preferred Keep a Changelog format) - # - ## 1.2.3 (without brackets) - # - ## [v1.2.3] (with v prefix) - # - # [1.2.3] (single # for projects not using nested headers) - # - # The regex breakdown: - # ^##? - Start of line, one or two # symbols - # \[? - Optional opening bracket - # v? - Optional 'v' prefix - # $VERSION - The actual version number - # \]? - Optional closing bracket - if grep -qE "^##? \[?v?$VERSION\]?" "$CHANGELOG"; then - echo "✅ Changelog entry found for version $VERSION" - echo "" - echo "Entry preview:" - # Show the version header and the next 10 lines to give context - grep -A 10 -E "^##? \[?v?$VERSION\]?" "$CHANGELOG" | head -15 - else - echo "❌ ERROR: No changelog entry found for version $VERSION" - echo "" - echo "Please add a changelog entry with one of these formats:" - echo " ## [$VERSION] - $(date +%Y-%m-%d)" - echo " ## $VERSION" - echo " ## [v$VERSION]" - echo "" - echo "Example:" - echo " ## [$VERSION] - $(date +%Y-%m-%d)" - echo " ### Added" - echo " - New feature X" - echo " ### Fixed" - echo " - Bug Y" - echo "" - echo "Current changelog preview:" - head -30 "$CHANGELOG" - exit 1 - fi - - # ========================================================================== - # CHECK 4: Semver Compatibility - # ========================================================================== - # Rationale: Prevents accidental breaking changes in patch and minor version - # bumps by comparing the API surface against the last published version. - # - # Why this matters: Semantic versioning is a contract with users. A patch - # bump (1.2.3 → 1.2.4) promises only bug fixes, no breaking changes. A minor - # bump (1.2.3 → 1.3.0) promises new features but no breaking changes. Only - # major bumps (1.2.3 → 2.0.0) can break compatibility. Breaking this contract - # causes downstream breakage and frustration. - # - # Semver rules applied: - # - For 1.0.0+: Breaking changes require major bump (X.0.0) - # - For 0.x.y: Breaking changes require minor bump (0.X.0) - # (0.x is considered unstable, so minor bump = breaking OK) - # - Patch bumps: Never allow breaking changes - # - # Tool: cargo-semver-checks analyzes the compiled crate's public API and - # detects breaking changes like removed functions, changed signatures, etc. - # ========================================================================== - - - name: Install cargo-semver-checks - uses: cargo-bins/cargo-binstall@main - - run: cargo binstall --no-confirm cargo-semver-checks - - - name: Check semver compatibility - run: | - echo "🔍 CHECK 4/5: Running semver checks..." - - CRATE="${{ steps.parse.outputs.crate }}" - - # Check if this crate has been published before - # If not, we can't run semver checks (nothing to compare against) - if ! cargo info "$CRATE" --registry crates-io &>/dev/null; then - echo "ℹ️ Crate not yet published to crates.io - skipping semver check" - echo " (First release has nothing to compare against)" - exit 0 - fi - - # Determine if breaking changes are allowed based on the version bump - MAJOR="${{ steps.parse.outputs.major }}" - MINOR="${{ steps.parse.outputs.minor }}" - PATCH="${{ steps.parse.outputs.patch }}" - - SKIP_CHECK=false - - # Check if this is a major version bump (X.0.0) - if [ "$MAJOR" != "0" ]; then - # For stable versions (1.0.0+), only X.0.0 allows breaking changes - if [ "$MINOR" == "0" ] && [ "$PATCH" == "0" ]; then - echo "ℹ️ Major version bump detected ($MAJOR.0.0)" - echo " Breaking changes are allowed per semver rules" - SKIP_CHECK=true - fi - else - # For pre-1.0 versions (0.x.y), 0.X.0 allows breaking changes - # Rationale: 0.x versions are considered unstable/development - if [ "$PATCH" == "0" ]; then - echo "ℹ️ Minor version bump in 0.x series (0.$MINOR.0)" - echo " Breaking changes are allowed in 0.x per semver rules" - SKIP_CHECK=true - fi - fi - - if [ "$SKIP_CHECK" = true ]; then - echo "⏭️ Skipping semver check (breaking changes expected for this bump)" - exit 0 - fi - - # Run semver checks - # If this fails, it means there are breaking changes but the version - # bump doesn't allow them (e.g., patch bump with breaking changes) - echo "Running cargo-semver-checks..." - echo "(Breaking changes are NOT allowed for this version bump)" - - if cargo semver-checks check-release -p "$CRATE"; then - echo "✅ No semver violations detected" - else - echo "" - echo "❌ ERROR: Semver violations detected!" - echo "" - echo "Breaking changes were found, but this version bump doesn't allow them." - echo "" - echo "Your options:" - echo " 1. Fix the breaking changes to maintain API compatibility" - if [ "$MAJOR" != "0" ]; then - echo " 2. Bump to next major version (e.g., $MAJOR.0.0 → $(($MAJOR + 1)).0.0)" - else - echo " 2. Bump to next minor version (e.g., 0.$MINOR.x → 0.$(($MINOR + 1)).0)" - fi - echo "" - echo "See cargo-semver-checks output above for details on what broke." - exit 1 - fi - - # ========================================================================== - # CHECK 5: Run Tests - # ========================================================================== - # Rationale: Final verification that the crate's tests pass before publish. - # - # Why this matters: Even though tests should have passed in CI on the PR, - # we run them again here as a final gate. This catches edge cases like: - # - Someone force-pushed changes after CI passed - # - Flaky tests that passed in CI but might fail now - # - Issues with the tag itself or checkout process - # - # Note: We use `-p ` to only test this specific crate, not the - # entire workspace. This is faster and only tests what we're publishing. - # ========================================================================== - - - name: Run tests - run: | - echo "🔍 CHECK 5/5: Running tests..." - - # -p flag: Run tests only for this specific crate - # This is important in a monorepo to avoid testing unrelated crates - cargo test -p ${{ steps.parse.outputs.crate }} - - echo "✅ All tests passed" - - # ========================================================================== - # PUBLISH: Publish to crates.io and Create GitHub Release - # ========================================================================== - # Rationale: All checks passed, now we can safely publish. - # - # Why two steps (crates.io + GitHub release): - # 1. crates.io publish - Makes the crate available to Rust users - # 2. GitHub release - Creates a release on GitHub with changelog notes, - # providing a nice UI for browsing releases and downloading source - # - # Note: Publishing to crates.io is IRREVERSIBLE. You cannot unpublish, - # only yank (which hides from new installs but doesn't delete). That's - # why we have all the checks above! - # ========================================================================== - - - name: Publish to crates.io - if: steps.parse.outputs.dry_run == 'false' - run: | - CRATE="${{ steps.parse.outputs.crate }}" - VERSION="${{ steps.parse.outputs.version }}" - echo "🚀 Publishing $CRATE v$VERSION to crates.io..." - - # Check if this version is already published (idempotent retries) - if cargo info "${CRATE}@${VERSION}" --registry crates-io &>/dev/null; then - echo "✅ $CRATE v$VERSION is already published on crates.io — skipping" - else - cargo publish -p "$CRATE" - echo "✅ Successfully published to crates.io!" - fi - echo "🔗 https://crates.io/crates/$CRATE" - env: - # The token is stored in GitHub Secrets for security - # To create one: https://crates.io/settings/tokens - # Add it to repo: Settings → Secrets and variables → Actions - CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }} - - - name: Create GitHub Release - if: steps.parse.outputs.dry_run == 'false' - uses: softprops/action-gh-release@v1 - with: - # Use the tag that triggered this workflow - tag_name: ${{ github.ref }} - - # Format: "mycrate v1.2.3" - name: ${{ steps.parse.outputs.crate }} v${{ steps.parse.outputs.version }} - - # Release notes body - # In the future, you could extract the changelog section here - # to automatically populate the release notes - body: | - Published ${{ steps.parse.outputs.crate }} v${{ steps.parse.outputs.version }} to crates.io - - 🔗 [View on crates.io](https://crates.io/crates/${{ steps.parse.outputs.crate }}) - - See [CHANGELOG](https://github.com/${{ github.repository }}/blob/${{ github.ref_name }}/CHANGELOG.md) for details. - env: - # GITHUB_TOKEN is automatically provided by GitHub Actions - # No need to create this secret manually - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Dry-run complete - if: steps.parse.outputs.dry_run == 'true' - run: | - echo "✅ DRY-RUN COMPLETE!" - echo "" - echo "All validation checks passed for ${{ steps.parse.outputs.crate }} v${{ steps.parse.outputs.version }}" - echo "" - echo "The following checks were successful:" - echo " ✅ Version matches Cargo.toml" - echo " ✅ Changelog format is valid" - echo " ✅ Changelog entry exists" - echo " ✅ Semver compatibility check passed" - echo " ✅ All tests passed" - echo "" - echo "To publish for real, push a tag:" - echo " git tag ${{ steps.parse.outputs.crate }}-v${{ steps.parse.outputs.version }}" - echo " git push origin ${{ steps.parse.outputs.crate }}-v${{ steps.parse.outputs.version }}" - -# ============================================================================== -# MAINTENANCE NOTES -# ============================================================================== -# -# Common modifications you might want to make: -# -# 1. Change tag format: -# - Modify the regex in the `on.push.tags` section -# - Update the parsing logic in the "Parse tag" step -# -# 2. Skip semver checks entirely (not recommended): -# - Remove or comment out CHECK 4 -# -# 3. Add additional checks: -# - cargo clippy for linting -# - cargo fmt --check for formatting -# - Documentation build check: cargo doc --no-deps -# -# 4. Auto-extract changelog for GitHub release: -# - Use kacl-cli or similar tool to extract the version section -# - Replace the static body in "Create GitHub Release" -# -# 5. Publish multiple crates at once: -# - This workflow publishes one crate at a time by design -# - For dependency order, consider using cargo-release instead -# -# 6. Customize python-kacl validation rules: -# - Create a .kacl.yml file in your crate directories -# - Pass it to kacl-cli: kacl-cli verify --config .kacl.yml -# -# Troubleshooting: -# -# - If semver-checks fails unexpectedly: -# Run locally: cargo semver-checks check-release -p -# -# - If changelog validation fails: -# Run locally: kacl-cli verify --json CHANGELOG.md | jq -# -# - If version mismatch: -# Ensure you updated Cargo.toml before tagging -# -# - If crate not found: -# Check workspace members in root Cargo.toml -# ============================================================================== + python3 .github/scripts/release_plan.py --select "${SELECT#,}" \ + ${{ inputs.dry_run && '--dry-run' || '' }} + + crates: + needs: plan + if: needs.plan.outputs.crates != '' + uses: ./.github/workflows/publish-crates.yml + with: + crates: ${{ needs.plan.outputs.crates }} + dry_run: ${{ inputs.dry_run }} + secrets: inherit + permissions: + contents: write + + # The bindings wait for the crates, but also run when there were none to + # publish. + python: + needs: [plan, crates] + if: >- + !failure() && !cancelled() && + (needs.plan.outputs.gl_client_py == 'true' || needs.plan.outputs.gl_sdk_py == 'true') + uses: ./.github/workflows/python.yml + with: + release: true + dry_run: ${{ inputs.dry_run }} + gl_client: ${{ needs.plan.outputs.gl_client_py == 'true' }} + gl_sdk: ${{ needs.plan.outputs.gl_sdk_py == 'true' }} + secrets: inherit + permissions: + contents: write + id-token: write + + npm: + needs: [plan, crates] + if: ${{ !failure() && !cancelled() && needs.plan.outputs.npm == 'true' }} + uses: ./.github/workflows/typescript.yml + with: + release: true + dry_run: ${{ inputs.dry_run }} + secrets: inherit + permissions: + contents: read + + swift: + needs: [plan, crates] + if: ${{ !failure() && !cancelled() && needs.plan.outputs.swift == 'true' }} + uses: ./.github/workflows/swift.yml + with: + release: true + dry_run: ${{ inputs.dry_run }} + secrets: inherit + permissions: + contents: write + + maven: + needs: [plan, crates] + if: ${{ !failure() && !cancelled() && needs.plan.outputs.maven == 'true' }} + uses: ./.github/workflows/kotlin.yml + with: + release: true + dry_run: ${{ inputs.dry_run }} + secrets: inherit + permissions: + contents: read From 04d81d86e771f664e75d5b7285be6e7a4e7b1764 Mon Sep 17 00:00:00 2001 From: cdecker Date: Thu, 19 Nov 2026 14:16:46 +0100 Subject: [PATCH 17/20] android: Publish an unsigned release bundle to build/maven-bundle `./gradlew :lib:publishAllPublicationsToBundleRepository` writes the publications in the Maven repository layout with checksums, unsigned, like Maven Local. GitHub builds it for a release, and the internal GitLab mirror signs and uploads it. --- libs/gl-sdk-android/lib/build.gradle.kts | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/libs/gl-sdk-android/lib/build.gradle.kts b/libs/gl-sdk-android/lib/build.gradle.kts index bb33d9ddb..69c8b95b7 100644 --- a/libs/gl-sdk-android/lib/build.gradle.kts +++ b/libs/gl-sdk-android/lib/build.gradle.kts @@ -138,12 +138,30 @@ extensions.configure { useGpgCmd() } -// Do not require signing when publishing to Maven Local +// The release bundle: the publications in the Maven repository layout, +// with checksums but unsigned, under build/maven-bundle. The Release +// workflow builds it with `./gradlew :lib:publishAllPublicationsToBundleRepository` +// and checks it with contrib/maven-central/check-bundle.sh. It is signed +// and uploaded to Maven Central where the signing key is. +publishing { + repositories { + maven { + name = "Bundle" + url = uri(layout.buildDirectory.dir("maven-bundle")) + } + } +} + +// Do not require signing when publishing to Maven Local or the bundle // Allows `./gradlew publishToMavenLocal` (or `publishToLocalMaven`) without GPG setup tasks.withType().configureEach { onlyIf { val taskNames = gradle.startParameter.taskNames - // Skip signing if the build is targeting the local Maven repository - taskNames.none { it.contains("publishToMavenLocal", ignoreCase = true) || it.contains("publishToLocalMaven", ignoreCase = true) } + // Skip signing if the build is targeting the local Maven repository or the bundle + taskNames.none { + it.contains("publishToMavenLocal", ignoreCase = true) || + it.contains("publishToLocalMaven", ignoreCase = true) || + it.contains("BundleRepository", ignoreCase = true) + } } } From 9fd6af674343c215485ddca6057c3d1d2e002759 Mon Sep 17 00:00:00 2001 From: cdecker Date: Thu, 19 Nov 2026 14:16:46 +0100 Subject: [PATCH 18/20] ci: Release Android as an unsigned bundle for Maven Central kotlin.yml, called by release.yml, builds the publications as an unsigned bundle in the Maven repository layout and runs it through contrib/maven-central/check-bundle.sh with a throwaway key: POM fields, the md5 and sha1 checksums, every file signed and verified. A real release attaches the bundle and its SHA-256 to the gl-sdk-vX.Y.Z release, where Blockstream's release infrastructure picks it up, signs it with Blockstream's key and uploads it, and waits until the version is on repo1.maven.org. No Maven credentials are on GitHub. It also ran on pushes to master, a branch this repository does not have, and on gl-sdk-* tags; it now runs on main. --- .github/workflows/kotlin.yml | 106 +++++++++++++++++++++++++- .github/workflows/release.yml | 2 +- contrib/maven-central/check-bundle.sh | 71 +++++++++++++++++ 3 files changed, 174 insertions(+), 5 deletions(-) create mode 100755 contrib/maven-central/check-bundle.sh diff --git a/.github/workflows/kotlin.yml b/.github/workflows/kotlin.yml index 238ea50e8..1dea792f6 100644 --- a/.github/workflows/kotlin.yml +++ b/.github/workflows/kotlin.yml @@ -1,10 +1,29 @@ +# Builds and tests the Kotlin Multiplatform library (Android, JVM, iOS). +# +# Called by release.yml, it also builds the Maven Central bundle of +# com.blockstream:glsdk: the publications in the Maven repository layout, +# unsigned. contrib/maven-central/check-bundle.sh checks it and signs it +# with a throwaway key, the way Central requires. A real release attaches +# the unsigned bundle to the gl-sdk-vX.Y.Z release, where Blockstream's +# release infrastructure picks it up within the hour, signs it with +# Blockstream's key and uploads it. No Maven credentials are on GitHub. +# The release then waits until the version is on repo1.maven.org. + on: push: branches: - - master - tags: - - 'gl-sdk-*' + - main pull_request: {} + workflow_dispatch: + # Publishing runs only when release.yml calls this workflow. + workflow_call: + inputs: + release: + type: boolean + default: false + dry_run: + type: boolean + default: true name: Kotlin library @@ -12,6 +31,8 @@ jobs: build: runs-on: macos-26 + outputs: + version: ${{ steps.bundle.outputs.version }} steps: - name: "Show default version of NDK" run: echo $ANDROID_NDK_ROOT @@ -63,14 +84,91 @@ jobs: run: | ./gradlew :lib:jvmTest --console=plain - - name: "Puiblish to Maven" + - name: "Publish to Maven Local" working-directory: libs/gl-sdk-android run: | ./gradlew :lib:publishToMavenLocal + - name: "Build the Maven Central bundle" + id: bundle + if: inputs.release + working-directory: libs/gl-sdk-android + run: | + VERSION=$(sed -n 's/^libraryVersion=//p' gradle.properties) + ./gradlew :lib:publishAllPublicationsToBundleRepository --console=plain + mkdir -p "$GITHUB_WORKSPACE/dist" + ZIP="$GITHUB_WORKSPACE/dist/glsdk-maven-$VERSION.zip" + (cd lib/build/maven-bundle && zip -q -r "$ZIP" com) + shasum -a 256 "$ZIP" | cut -d' ' -f1 > "$ZIP.sha256" + echo "version=$VERSION" >> "$GITHUB_OUTPUT" + + # What Central checks, with a throwaway key. + - name: "Check the bundle" + if: inputs.release + run: | + VERSION=${{ steps.bundle.outputs.version }} + GNUPGHOME=$(mktemp -d) + export GNUPGHOME + gpg --batch --passphrase '' --quick-gen-key "glsdk release dry run " ed25519 sign never + KEY=$(gpg --list-keys --with-colons | awk -F: '/^fpr/ {print $10; exit}') + contrib/maven-central/check-bundle.sh "dist/glsdk-maven-$VERSION.zip" "$VERSION" "$KEY" "$RUNNER_TEMP/signed.zip" + + - uses: actions/upload-artifact@v4 + if: inputs.release + with: + name: maven-bundle + path: dist/ + if-no-files-found: error + - name: Temporarily save artifact uses: actions/upload-artifact@v4 with: name: glsdk-artifact path: libs/gl-sdk-android/lib/build/outputs/ retention-days: 14 + + attach: + name: Attach the Maven bundle to the gl-sdk release + if: inputs.release && !inputs.dry_run + needs: build + runs-on: ubuntu-latest + permissions: + contents: write + env: + GH_TOKEN: ${{ github.token }} + GH_REPO: ${{ github.repository }} + TAG: gl-sdk-v${{ needs.build.outputs.version }} + steps: + - uses: actions/download-artifact@v4 + with: + name: maven-bundle + path: dist + + # publish-crates.yml creates the release when it publishes the gl-sdk + # crate. A Maven-only release creates it here. + - name: Upload the bundle + run: | + if ! gh release view "$TAG" >/dev/null 2>&1; then + gh release create "$TAG" --target "$GITHUB_SHA" --title "gl-sdk ${TAG#gl-sdk-v}" \ + --notes "See the [gl-sdk changelog](https://github.com/$GH_REPO/blob/$TAG/libs/gl-sdk/CHANGELOG.md)." \ + || gh release view "$TAG" >/dev/null # created concurrently + fi + gh release upload "$TAG" --clobber dist/glsdk-maven-*.zip dist/glsdk-maven-*.zip.sha256 + gh release view "$TAG" --json assets --jq '.assets[].name' + + # The bundle is picked up within the hour, then Central validates, + # publishes and syncs to repo1.maven.org. + published: + name: Wait for Maven Central + needs: [build, attach] + runs-on: ubuntu-latest + timeout-minutes: 180 + env: + VERSION: ${{ needs.build.outputs.version }} + steps: + - name: Wait for the release on repo1.maven.org + run: | + echo "::notice::Waiting for com.blockstream:glsdk:$VERSION on Maven Central, usually within 90 minutes" + URL="https://repo1.maven.org/maven2/com/blockstream/glsdk/$VERSION/glsdk-$VERSION.pom" + until curl -fsI "$URL" >/dev/null; do sleep 120; done + echo "com.blockstream:glsdk:$VERSION is on Maven Central" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f8e10d556..38b40af1e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -152,4 +152,4 @@ jobs: dry_run: ${{ inputs.dry_run }} secrets: inherit permissions: - contents: read + contents: write diff --git a/contrib/maven-central/check-bundle.sh b/contrib/maven-central/check-bundle.sh new file mode 100755 index 000000000..32d0cfbb8 --- /dev/null +++ b/contrib/maven-central/check-bundle.sh @@ -0,0 +1,71 @@ +#!/usr/bin/env bash +# Checks a com.blockstream:glsdk release bundle and signs it the way Maven +# Central requires. +# +# check-bundle.sh +# +# The bundle is what `./gradlew :lib:publishAllPublicationsToBundleRepository` +# writes to libs/gl-sdk-android/lib/build/maven-bundle, zipped: the +# publications in the Maven repository layout, unsigned. This checks the +# layout and the POMs, writes the md5 and sha1 checksums Central requires, +# signs every file with the given key from the gpg keyring, checks the +# signatures and zips the result to , ready for the Central +# Portal's upload API. MAVEN_SIGNING_KEY_PASSWORD is the key's passphrase, +# if it has one. +# +# The Release workflow runs it with a throwaway key on every release, dry +# run or not, so a bundle that Central would reject never leaves GitHub. +# Runs on macOS (bash 3.2) and Linux. +set -euo pipefail + +[ $# = 4 ] || { echo "usage: $0 " >&2; exit 2; } +ZIP=$(cd "$(dirname "$1")" && pwd)/$(basename "$1") +VERSION=$2 KEY_ID=$3 +OUT=$(cd "$(dirname "$4")" && pwd)/$(basename "$4") + +digest() { openssl dgst "-$1" "$2" | sed 's/.*= //'; } + +WORK=$(mktemp -d) +trap 'rm -rf "$WORK"' EXIT +mkdir "$WORK/in" "$WORK/out" +unzip -q "$ZIP" -d "$WORK/in" +cd "$WORK/in" + +# Only the version directories go to Central. Gradle also writes +# maven-metadata.xml one level up, which Central does not take. +DIRS=$(find . -type d -path "./com/blockstream/glsdk*/$VERSION" | sort) +[ -n "$DIRS" ] || { echo "error: no com/blockstream/glsdk*/$VERSION in $ZIP" >&2; exit 1; } +for d in $DIRS; do + mkdir -p "$WORK/out/$d" + find "$d" -maxdepth 1 -type f ! -name '*.md5' ! -name '*.sha1' ! -name '*.sha256' ! -name '*.sha512' ! -name '*.asc' \ + -exec cp {} "$WORK/out/$d/" \; +done +cd "$WORK/out" + +for d in $DIRS; do + NAME=$(basename "$(dirname "$d")") + POM="$d/$NAME-$VERSION.pom" + [ -f "$POM" ] || { echo "error: $NAME has no $NAME-$VERSION.pom" >&2; exit 1; } + # What Central requires of every POM. + for tag in name description url licenses developers scm; do + grep -q "<$tag>" "$POM" || { echo "error: $POM has no <$tag>" >&2; exit 1; } + done + for c in sources javadoc; do + [ -f "$d/$NAME-$VERSION-$c.jar" ] || echo "warning: $NAME has no $c jar, Central may reject it" >&2 + done +done + +FILES=$(find . -type f | sort) +for f in $FILES; do + digest md5 "$f" > "$f.md5" + digest sha1 "$f" > "$f.sha1" + printf '%s' "${MAVEN_SIGNING_KEY_PASSWORD:-}" | gpg --batch --yes --quiet --pinentry-mode loopback --passphrase-fd 0 \ + --local-user "$KEY_ID" --armor --detach-sign --output "$f.asc" "$f" + gpg --batch --quiet --verify "$f.asc" "$f" 2>/dev/null || { echo "error: the signature of $f does not verify" >&2; exit 1; } +done +echo "Signed $(echo "$FILES" | wc -l | tr -d ' ') files with $KEY_ID:" +echo "$FILES" | sed 's/^/ /' + +rm -f "$OUT" +zip -q -r "$OUT" com +echo "com.blockstream:glsdk:$VERSION is ready for Maven Central: $OUT" From b4d32bcc83a6c97baa462050a357dbddf294fdce Mon Sep 17 00:00:00 2001 From: cdecker Date: Thu, 19 Nov 2026 13:59:30 +0100 Subject: [PATCH 19/20] docs: Describe the Release workflow --- docs/src/reference/releases.md | 195 +++++++++++++++++---------------- 1 file changed, 99 insertions(+), 96 deletions(-) diff --git a/docs/src/reference/releases.md b/docs/src/reference/releases.md index d296f6fb9..08ecad6d4 100644 --- a/docs/src/reference/releases.md +++ b/docs/src/reference/releases.md @@ -1,73 +1,105 @@ # Releasing the Greenlight SDK This page documents how a version of the Greenlight SDK is cut and -published, and which automation is (and is not) wired up. The SDK is a -Cargo workspace that is published to several registries at once, so a -release touches multiple pipelines with slightly different triggers and -failure modes. +published. The SDK is a Cargo workspace with bindings for several +languages, published to five registries. One workflow releases all of +them: **Actions > Release > Run workflow** in `Blockstream/greenlight`. ## What gets published, and by what -| Artifact | Workflow | Trigger | Registry | -| --- | --- | --- | --- | -| `gl-client`, `gl-plugin`, `gl-signerproxy`, `gl-cli`, `gl-sdk`, `gl-sdk-cli` (Rust) | `.github/workflows/release.yml` | push of a `-vX.Y.Z` tag | crates.io | -| `gl-client` (Python, `libs/gl-client-py`) | `.github/workflows/python.yml` | push of a `gl-client-py-vX.Y.Z` tag | PyPI (trusted publishing) | -| `gl-sdk` (Python, `libs/gl-sdk`) | `.github/workflows/python.yml` | push of a `gl-sdk-vX.Y.Z` tag | PyPI (trusted publishing) | -| `@greenlightcln/glsdk` (npm) | `.github/workflows/typescript.yml` | push to `main` whose `package.json` version is not on npm yet | npm | -| `com.blockstream:glsdk` (Android, JVM) | `gitlab/deploy-maven.yml` on the internal GitLab mirror | manual `publish_to_maven` job on a tag pipeline | Maven Central | -| `GreenlightSDK` (Swift) | `.github/workflows/swift.yml` builds it, `publish.yml` in `Blockstream/gl-sdk-swift` publishes it | push of a `gl-sdk-vX.Y.Z` tag; `gl-sdk-swift` picks it up within the hour | tag and GitHub Release `X.Y.Z` in `gl-sdk-swift` | -| `clnvm` (Python) | `task clnvm:publish` (manual `twine`) | manual | PyPI | +| Group | Artifact | Version from | Registry | Workflow | +| --- | --- | --- | --- | --- | +| crates | `gl-client`, `gl-util`, `gl-plugin`, `gl-signerproxy`, `gl-cli`, `gl-sdk`, `gl-sdk-cli` | each `Cargo.toml` | crates.io | `publish-crates.yml` | +| python | `gl-client` (`libs/gl-client-py`) | its `pyproject.toml` | PyPI | `python.yml` | +| python | `gl-sdk` (`libs/gl-sdk`) | its `pyproject.toml` | PyPI | `python.yml` | +| npm | `@greenlightcln/glsdk` | `libs/gl-sdk-napi/package.json` | npm | `typescript.yml` | +| swift | `GreenlightSDK` | the `gl-sdk` crate | tag `X.Y.Z` in `Blockstream/gl-sdk-swift` | `swift.yml` | +| maven | `com.blockstream:glsdk` | `libraryVersion` in `libs/gl-sdk-android/gradle.properties` | Maven Central | `kotlin.yml` | +| | `clnvm` (Python) | | PyPI | manual `task clnvm:publish` | -## Tag conventions +`release.yml` calls the other workflows. On their own, on pushes and +pull requests, they only build and test. Pushing a release tag no +longer publishes anything. -The crates.io workflow fires on any tag matching: +## Cutting a release -```text -*-v[0-9]+.[0-9]+.[0-9]+ -``` +1. **Bump versions and changelogs.** Set the new version of everything + going out, and move the `Unreleased` section of each `CHANGELOG.md` + under a dated version heading. The plan job enforces that the + bindings of one SDK release agree: + - `libs/gl-sdk/pyproject.toml` and `libraryVersion` match the + `gl-sdk` crate; the Swift package always takes the crate's version; + - `libs/gl-client-py/pyproject.toml` matches the `gl-client-py` + crate, and `package.json` matches the `gl-sdk-node` crate. +2. **Merge to `main`.** +3. **Run a dry run**: Actions > Release > Run workflow, with *Dry run* + ticked (the default). It runs from any branch, so a release can also + be tried before merging. +4. **Run the release** from `main` with *Dry run* unticked. Untick the + groups that should not go out. -so a release tag looks like `gl-client-v0.7.0`. Everything before the -last `-v` is taken as the crate name and the rest as the version. The -workflow then enforces a **"Version Match"** check: the tag version must -equal the `version` in that crate's `Cargo.toml`. +The plan job asks each registry whether the version from the +repository is published and writes a table of what the run will do to +the run's summary page. A real release publishes only what is missing, +so re-running a partly failed release finishes it. A dry run exercises +every selected artifact, published or not, so it can run at any time, +for example to check that the release pipeline still works. -The same pattern also matches the Python release tags. A -`gl-sdk-vX.Y.Z` tag therefore publishes both the `gl-sdk` crate and the -`gl-sdk` Python package. The `gl-client-py` crate sets `publish = false`, -so `release.yml` skips `gl-client-py-vX.Y.Z` tags and only -`python.yml` acts on them. `python.yml` checks that every built wheel -carries the version from the tag, which comes from the package's -`pyproject.toml`. +The crates go first, the bindings after them in parallel, so a binding +never ships a `gl-sdk` version whose crates failed to publish. -## Cutting a release +## What a dry run checks -1. **Bump versions and changelogs.** For each crate going out, set - `version` in its `Cargo.toml` (and `package.json` for the npm - binding), and move the `Unreleased` section of its `CHANGELOG.md` - under a dated version heading. -2. **Merge to `main`.** -3. **Publish the Rust crates** by pushing one semver tag per crate, on - the commit whose `Cargo.toml` matches: - - ```bash - git tag -a gl-client-v0.7.0 - git tag -a gl-sdk-v0.5.0 - git tag -a gl-sdk-cli-v0.4.0 - git push origin --tags - ``` - -4. **Publish in dependency order.** The higher-level crates depend on - the lower-level ones, so publish (or re-run) `gl-client` first, then - `gl-plugin`, `gl-signerproxy`, `gl-cli` and `gl-sdk`, then - `gl-sdk-cli`. If they race, the dependent crate fails - with `failed to select a version for the requirement gl-client = ...` - simply because its dependency is not on crates.io yet. The publish - step is idempotent — anything already on crates.io is skipped — so a - re-run after the dependency lands is enough; the tags do not need to - be re-pushed. - -5. **The npm binding** is published automatically by `typescript.yml` on - the merge push (see the gotcha below). +Every publication step has a dry-run mode that stops right before the +upload: + +| Group | Dry run | Real release adds | +| --- | --- | --- | +| crates | changelog format and entry, `cargo semver-checks` against the last release, tests, and `cargo publish --dry-run` of all crates together. Cargo builds each against the others' packages through a local registry overlay, so this passes before any of them is on crates.io. | the upload in dependency order, and a `-vX.Y.Z` GitHub release per crate | +| python | the wheels and sdist are built and smoke tested, and carry the expected version; `twine check --strict` | the upload, and a `gl-client-py-vX.Y.Z` GitHub release | +| npm | the native modules are built for every platform and tested; `npm publish --dry-run` | the upload | +| swift | the XCFramework is built; gl-sdk-swift's `scripts/prepare.sh` renders, commits and tags the package locally, and `scripts/check-package.sh` compiles it for the iOS simulator against the fresh zip | the assets on the `gl-sdk-vX.Y.Z` release, then a wait for gl-sdk-swift to tag `X.Y.Z` and a check of it the way SwiftPM installs it | +| maven | the library is built and tested, and the Maven Central bundle is built and run through `contrib/maven-central/check-bundle.sh` with a throwaway key: POM fields, checksums, every file signed and verified | the unsigned bundle on the `gl-sdk-vX.Y.Z` release, then a wait until it is on repo1.maven.org | + +The plan also catches what only a registry would reject otherwise, such +as a wildcard (`"*"`) dependency requirement, which crates.io refuses +on upload. To see the plan without running anything: + +```bash +python3 .github/scripts/release_plan.py --dry-run +``` + +## The Swift package + +SwiftPM resolves packages by repository, so the package lives in +`Blockstream/gl-sdk-swift` while greenlight builds it. Neither +repository writes to the other, so no cross-repository token is needed: + +1. `swift.yml` attaches `glsdkFFI.xcframework.zip`, its checksum and + `glsdk.swift` to the `gl-sdk-vX.Y.Z` release here. +2. `publish.yml` in gl-sdk-swift polls hourly for such releases, commits + a `Package.swift` whose binary target points at the zip here, and + tags and releases `X.Y.Z` there. +3. `swift.yml` waits for that tag, for up to two hours, and verifies it. + To skip the wait, run `publish.yml` in gl-sdk-swift by hand. + +`swift.yml` runs gl-sdk-swift's scripts from its `main` branch in every +build, so changes to the templates there are tested here. GitHub +disables a scheduled workflow after 60 days without activity in its +repository; if a release waits forever, re-enable `publish.yml` on +gl-sdk-swift's Actions tab. + +## The Maven package + +GitHub holds no Maven Central credentials or signing key. `kotlin.yml` +builds the publications, unsigned, in the Maven repository layout +(`./gradlew :lib:publishAllPublicationsToBundleRepository`), checks them +with `contrib/maven-central/check-bundle.sh` and a throwaway key, and +attaches them to the `gl-sdk-vX.Y.Z` release as `glsdk-maven-X.Y.Z.zip` +with its `.sha256`. Blockstream's release infrastructure picks the +bundle up within the hour, signs it with Blockstream's key and uploads +it. `kotlin.yml` waits, for up to three hours, until the version is on +repo1.maven.org. ## Cargo manifest requirements @@ -86,45 +118,30 @@ license = "MIT" repository = "https://github.com/Blockstream/greenlight" ``` -(As of the `v26.06gl1` release, `gl-sdk-cli` was missing these and -needed a small follow-up before it would publish.) - -## Secrets +Every workspace crate is released unless it sets `publish = false`, as +`gl-examples`, `uniffi-bindgen`, `gl-client-py` and `gl-sdk-node` do. -Publishing reads these GitHub Actions secrets (in -`Blockstream/greenlight`): +## Secrets and registry setup -| Secret | Consumed by | Notes | +| Secret or setting | Used by | Notes | | --- | --- | --- | -| `CRATES_IO_TOKEN` | `release.yml` | crates.io publishing | +| `CRATES_IO_TOKEN` | `publish-crates.yml` | crates.io publishing | | `NPM_TOKEN` | `typescript.yml` | npm publishing | -| *(none)* | `python.yml` | PyPI, through trusted publishing in the `pypi` environment | +| PyPI trusted publisher | `python.yml` | per PyPI project: owner `Blockstream`, repository `greenlight`, workflow **`release.yml`**, environment `pypi`. The OIDC token names the workflow that started the run, not the called `python.yml`. For a project not on PyPI yet, add a *pending* publisher. | | `TWINE_PASSWORD` | manual `task clnvm:publish` only | PyPI; not used by CI | -| `CARGO_REGISTRY_TOKEN` | *none* | orphaned — `release.yml` maps the env var from `CRATES_IO_TOKEN` instead | -| `RELEASE_PLZ_TOKEN` | *none* | orphaned — `release-plz.toml` exists but no workflow runs release-plz | +| `CARGO_REGISTRY_TOKEN` | *none* | orphaned, `publish-crates.yml` maps the env var from `CRATES_IO_TOKEN` instead | +| `RELEASE_PLZ_TOKEN` | *none* | orphaned, `release-plz.toml` exists but no workflow runs release-plz | Long-lived tokens must be **rotated roughly every 90 days**, or immediately on any auth failure such as a `403 authentication failed` from `cargo publish`. To rotate a crates.io token: sign in to crates.io as an owner of *all* published crates, create a token with `publish-new` + `publish-update` (leave the IP prefix blank, since the -runners use dynamic IPs), then update `CRATES_IO_TOKEN` and re-publish -in dependency order. +runners use dynamic IPs), then update `CRATES_IO_TOKEN` and re-run the +release. ## Gaps and gotchas -- **npm publishes whatever version is missing from the registry.** - `typescript.yml` builds, tests and publishes when the `package.json` - version is not in the registry's version list for `@greenlightcln/glsdk`. - It compared against the parent commit before, which skipped the - publish after a rebase-merge buried the version bump below the tip, - and that left npm at 0.1.1 while `package.json` said 0.3.0. -- **PyPI trusted publishing has to be set up on pypi.org.** The publish - jobs in `python.yml` run in the `pypi` GitHub environment and - authenticate with the workflow's OIDC token. Each PyPI project needs a - trusted publisher for owner `Blockstream`, repository `greenlight`, - workflow `python.yml` and environment `pypi`. For a project that does - not exist on PyPI yet, add it as a *pending* publisher. - **The `gl-sdk` Python wheel is retagged.** hatchling builds it as `py3-none-any`, but it bundles the native library, so `python.yml` retags each wheel with the platform the library was built for. The @@ -132,17 +149,3 @@ in dependency order. which is what the `manylinux_2_17` tag promises. The bindings in the wheel are regenerated from the bundled library, and the job warns if the committed `libs/gl-sdk/glsdk/glsdk.py` differs from them. -- **The Swift package is published from `gl-sdk-swift`.** SwiftPM - resolves packages by repository, so the package lives there, while - greenlight builds it. `swift.yml` builds the XCFramework and the - bindings on every change to the SDK, compiles them as a Swift package - for the iOS simulator, and on a `gl-sdk-vX.Y.Z` tag attaches - `glsdkFFI.xcframework.zip`, its checksum and `glsdk.swift` to the - `gl-sdk-vX.Y.Z` release here. `publish.yml` in `gl-sdk-swift` polls - hourly for such releases, commits a `Package.swift` whose binary - target points at the zip in greenlight's release, and tags and - releases `X.Y.Z` there. Neither repository writes to the other, so no - cross-repository token is needed. To publish sooner or retry, run - `publish.yml` in `gl-sdk-swift` by hand. GitHub disables its schedule - after 60 days without activity in that repository; re-enable it on - the Actions tab. From 8fb8f33899d4803ffc11f57cd932c42179ad1352 Mon Sep 17 00:00:00 2001 From: cdecker Date: Thu, 19 Nov 2026 15:11:26 +0100 Subject: [PATCH 20/20] ci: Remove the GitLab pipeline The internal GitLab mirror ran the Kotlin snapshots and the manual Maven Central release from this tree. Releases are started from the Release workflow here now, and the Maven Central upload happens outside this repository, from the bundle the workflow attaches to the gl-sdk release. Maven -SNAPSHOT builds are no longer published. --- .gitlab-ci.yml | 20 ---------- gitlab/README.md | 21 ----------- gitlab/deploy-maven.yml | 82 ----------------------------------------- gitlab/functions.yml | 45 ---------------------- 4 files changed, 168 deletions(-) delete mode 100644 .gitlab-ci.yml delete mode 100644 gitlab/README.md delete mode 100644 gitlab/deploy-maven.yml delete mode 100644 gitlab/functions.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index be20e2bb2..000000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,20 +0,0 @@ -variables: - GIT_DEPTH: 1 - CI_IMAGE: blockstream/gli-ci - -stages: - - build - - deploy - -default: - image: ${CI_IMAGE}:${CI_IMAGE_VER} # set in CI env vars - -include: - - gitlab/**.yml - -## disables MR-triggered pipelines and allows only branch-triggered pipelines -workflow: - rules: - - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' - when: never - - when: always diff --git a/gitlab/README.md b/gitlab/README.md deleted file mode 100644 index 01019fe69..000000000 --- a/gitlab/README.md +++ /dev/null @@ -1,21 +0,0 @@ -## Gitlab Pipelines - -The internal GitLab mirror of this repository only builds and publishes -the Android/JVM library, `com.blockstream:glsdk`, to Maven Central. -Every other package is published from GitHub Actions, see -[the release docs](../docs/src/reference/releases.md). - -The mirror is updated by pushing `main` and the release tags to it. - -### Maven Central - -* `build_kotlin` runs on every tag and on `main`, on the `m4` macOS runner. -* `publish_to_maven` is a manual job on tag pipelines. It publishes the - version in `libs/gl-sdk-android/gradle.properties` (`libraryVersion`), - not the version in the tag, so run it once per release, on the - `gl-sdk-vX.Y.Z` tag's pipeline. -* `publish_snapshot_to_maven` publishes a `-SNAPSHOT` build on every - branch pipeline. - -The Maven Central credentials and the GPG signing key are configured in -the runner's `~/.gradle/gradle.properties`. diff --git a/gitlab/deploy-maven.yml b/gitlab/deploy-maven.yml deleted file mode 100644 index f97141fa1..000000000 --- a/gitlab/deploy-maven.yml +++ /dev/null @@ -1,82 +0,0 @@ -build_kotlin: - stage: build - tags: - - m4 - rules: - - if: "$CI_COMMIT_TAG" - - if: '$CI_COMMIT_BRANCH == "main"' - before_script: - # The desktop libraries bundled in the jvm jar - - rustup target add aarch64-apple-darwin x86_64-apple-darwin aarch64-unknown-linux-gnu x86_64-unknown-linux-gnu aarch64-pc-windows-msvc x86_64-pc-windows-msvc - # cargo-xwin archives the Windows libraries with the llvm-ar of llvm-tools - - rustup component add llvm-tools - # cargo-zigbuild cross builds the Linux libraries with zig - - command -v zig >/dev/null || brew install zig - script: - - task build:kotlin - artifacts: - paths: - - libs/gl-sdk-android/lib/src/androidMain/jniLibs - - libs/gl-sdk-android/lib/src/androidMain/kotlin - - libs/gl-sdk-android/lib/src/jvmMain - - libs/gl-sdk-android/lib/src/lib - - libs/gl-sdk-android/lib/src/commonMain - - libs/gl-sdk-android/lib/src/nativeMain - - libs/gl-sdk-android/lib/src/nativeInterop - expire_in: 1 day - -# maven credentials and gpg settings -# in runner's ~/.gradle/gradle.properties -publish_to_maven: - stage: deploy - tags: - - m4 - rules: - - if: "$CI_COMMIT_TAG" - when: manual - needs: - - job: build_kotlin - artifacts: true - script: - - cd libs/gl-sdk-android - - ./gradlew publish --no-daemon - artifacts: - paths: - - libs/gl-sdk-android/lib/build/libs - - libs/gl-sdk-android/lib/build/outputs - - libs/gl-sdk-android/lib/build/publications - when: always - expire_in: 7 days - allow_failure: true - -publish_snapshot_to_maven: - stage: deploy - tags: - - m4 - needs: - - job: build_kotlin - artifacts: true - rules: - - if: '$CI_COMMIT_BRANCH' - when: on_success - script: - - cd libs/gl-sdk-android - - RAW_VERSION=$(grep '^libraryVersion=' gradle.properties | cut -d'=' -f2) - - BASE_VERSION=${RAW_VERSION%-SNAPSHOT} - - VERSION_CORE=$(echo "$BASE_VERSION" | sed -E 's/[^0-9.].*$//') - - IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION_CORE" - - MAJOR=${MAJOR:-0} - - MINOR=${MINOR:-0} - - PATCH=${PATCH:-0} - - NEXT_PATCH=$((PATCH + 1)) - - NEXT_VERSION="${MAJOR}.${MINOR}.${NEXT_PATCH}" - - SNAPSHOT_VERSION="${NEXT_VERSION}-SNAPSHOT" - - SNAPSHOT_VERSION_COMMIT="${NEXT_VERSION}-${CI_COMMIT_SHORT_SHA}-SNAPSHOT" - - | - if [ "$CI_COMMIT_BRANCH" = "master" ]; then - echo "Publishing snapshot versions ${SNAPSHOT_VERSION}" - ./gradlew -PlibraryVersion=${SNAPSHOT_VERSION} publish --no-daemon - fi - echo "Publishing snapshot version ${SNAPSHOT_VERSION_COMMIT}" - ./gradlew -PlibraryVersion=${SNAPSHOT_VERSION_COMMIT} publish --no-daemon - allow_failure: true diff --git a/gitlab/functions.yml b/gitlab/functions.yml deleted file mode 100644 index c02b1f49b..000000000 --- a/gitlab/functions.yml +++ /dev/null @@ -1,45 +0,0 @@ -.build_setup: - stage: build - tags: - - cloud - rules: - - if: $CI_COMMIT_BRANCH - retry: - max: 2 - when: - - runner_system_failure - - unknown_failure - - stuck_or_timeout_failure - -build_ci_image: - extends: .build_setup - variables: - DOCKER_DRIVER: overlay2 - DOCKER_HOST: tcp://localhost:2375 - DOCKER_TLS_CERTDIR: "" - DOCKER_BUILDKIT: 1 - image: - name: docker:24-dind - services: - - docker:24-dind - rules: - - if: $CI_COMMIT_BRANCH - changes: - paths: - - docker/ci.Dockerfile - compare_to: main - script: - - docker pull ${CI_IMAGE}:latest || true - - export IMAGE_TAG=${CI_COMMIT_SHORT_SHA}-$(date +%Y%m%d) - - cd docker - - > - docker build - -f ci.Dockerfile - --network=host - --build-arg BUILDKIT_INLINE_CACHE=1 - --cache-from ${CI_IMAGE}:latest - -t ${CI_IMAGE}:${IMAGE_TAG} - -t ${CI_IMAGE}:latest - . - - docker push ${CI_IMAGE}:${IMAGE_TAG} - - docker push ${CI_IMAGE}:latest