# Publishes HUD's SDK at the version Cargo.toml names, the one version of # every package (knope.toml), to HUD's registries on knotless (docs/sdk.md): # @hud/renderer, @hud/shared and @hud/shell to its npm registry, HUDKit to # its Swift package registry as hud.HUDKit, and hudkit to its Maven # repository as place.hud:hudkit; then tags the commit v, as the # owner, so a checkout finds the version by name. A version is released # only with its CHANGELOG.md section, which release-pull.yml writes. # # A release is cut by asking for it at main, never by a push: # # knotless run rerun knotless://chadtmiller.com/hud --ref refs/heads/main --workflow release # # Asked for at any other branch, it builds every package and publishes # nothing, to try the build. Each publication is skipped where its version # is out already (a registry refuses a version twice), so a run that failed # partway is asked for again to finish. Until knotless.dev answers the Swift # and Maven registries (every answer under /swift/ carries `Content-Version: # 1`, and a refusal under /maven/ is text/plain where the site's own 404 is # HTML), those two are built, skipped and said so. # # RELEASE_PASSWORD is an app password of the owner's, chadtmiller.com, # granted to main alone in the runner's secrets. # Its secrets are on ci.knotless.dev alone, the runner that runs only its # owner's repositories. runners: [ci.knotless.dev] on: asked: {refs: [refs/heads/*]} superseded: finish # A JDK for Gradle, and the Android SDK and Node installed below. image: eclipse-temurin:17-jdk-noble cache: [/opt/node, /opt/android, /root/.gradle, web/node_modules] secrets: [RELEASE_PASSWORD] env: REPO: knotless://chadtmiller.com/hud OWNER: chadtmiller.com KNOTLESS_APPVIEW: https://knotless.dev # HUD's registries: each is the repository's, named by its owner's DID # and its key. NPM_REGISTRY: https://knotless.dev/npm/did:plc:bcgltzqazw5tb6k2g3ttenbj/3n2kdckpvmnlo/ SWIFT_REGISTRY: https://knotless.dev/swift/did:plc:bcgltzqazw5tb6k2g3ttenbj/3n2kdckpvmnlo/ HUD_MAVEN_URL: https://knotless.dev/maven/did:plc:bcgltzqazw5tb6k2g3ttenbj/3n2kdckpvmnlo/ ANDROID_HOME: /opt/android # The Android SDK's command-line tools (23.0), by the SHA-1 Google's # repository index gives them; the tools step installs into ANDROID_HOME # the platform and build tools hudkit needs, accepting their licences. ANDROID_TOOLS: commandlinetools-linux-16111833_latest.zip ANDROID_TOOLS_SHA1: e025545c62a8e64c7559119566a569fb1dec5f60 steps: - name: tools run: | apt-get update -qq apt-get install -y -qq --no-install-recommends curl git unzip xz-utils >/dev/null git config --global --add safe.directory "$PWD" if [ ! -x "$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager" ]; then cd /tmp curl -fsSLO "https://dl.google.com/android/repository/$ANDROID_TOOLS" echo "$ANDROID_TOOLS_SHA1 $ANDROID_TOOLS" | sha1sum -c - rm -rf "$ANDROID_HOME/cmdline-tools" mkdir -p "$ANDROID_HOME/cmdline-tools" unzip -q "$ANDROID_TOOLS" -d "$ANDROID_HOME/cmdline-tools" mv "$ANDROID_HOME/cmdline-tools/cmdline-tools" "$ANDROID_HOME/cmdline-tools/latest" rm "$ANDROID_TOOLS" fi # This cmdline-tools no longer writes licences on --licenses: install the # platform hudkit compiles against (compileSdk) and the build tools its # Android Gradle plugin uses, accepting each one's licence as it goes. yes | "$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager" --install "platforms;android-37.0" "build-tools;36.0.0" >/dev/null ls "$ANDROID_HOME/licenses" "$ANDROID_HOME/platforms" "$ANDROID_HOME/build-tools" curl -fsSL https://knotless.dev/install.sh | KNOTLESS_INSTALL_DIR=/usr/local/bin sh - uses: chadtmiller.com/steps/node@1 with: {version: 24.22.1} - uses: chadtmiller.com/steps/npm-ci@1 name: packages with: {dir: web} - name: version run: | version=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -1) echo "$version" > ~/.version echo "HUD $version, at $KNOTLESS_RUN_REF" [ "$KNOTLESS_RUN_REF" = refs/heads/main ] || echo "not main: building every package, publishing nothing" grep -q "^## $version\( \|$\)" CHANGELOG.md || { echo "CHANGELOG.md has no section for $version"; exit 1; } - name: build npm run: | mkdir -p ~/npm cd web npm run package for p in renderer shared shell; do npm pack -w "$p" --pack-destination ~/npm; done - name: build swift run: | version=$(cat ~/.version) # SwiftPM takes a source archive of one directory holding # Package.swift: HUDKit's, from ios/HUDKit, as it is at this commit. git archive --format=zip --prefix=HUDKit/ -o ~/HUDKit-"$version".zip "$KNOTLESS_RUN_SHA:ios/HUDKit" ls -l ~/HUDKit-"$version".zip - name: build maven timeout: 30 run: | # The AAR, its sources, its POM and module metadata, as they will be published. cd android && ./gradlew :hudkit:publishToMavenLocal --console=plain --no-daemon ls ~/.m2/repository/place/hud/hudkit/"$(cat ~/.version)" - name: publish npm on: {refs: [refs/heads/main]} run: | version=$(cat ~/.version) # npm's token here is `:`. echo "//${NPM_REGISTRY#https://}:_authToken=$OWNER:$RELEASE_PASSWORD" > ~/.npmrc for p in renderer shared shell; do if npm view "@hud/$p@$version" version --registry "$NPM_REGISTRY" 2>/dev/null | grep -qxF "$version"; then echo "@hud/$p $version is published already" else npm publish ~/npm/hud-"$p"-"$version".tgz --registry "$NPM_REGISTRY" fi done rm ~/.npmrc - name: publish swift on: {refs: [refs/heads/main]} run: | version=$(cat ~/.version) accept='Accept: application/vnd.swift.registry.v1+json' if ! curl -sI "${SWIFT_REGISTRY}hud/HUDKit" | grep -qi '^content-version: *1'; then echo "knotless.dev has no Swift registry yet: hud.HUDKit $version is not published" elif curl -fsS -o /dev/null -H "$accept" "${SWIFT_REGISTRY}hud/HUDKit/$version"; then echo "hud.HUDKit $version is published already" else curl -fsS -X PUT -u "$OWNER:$RELEASE_PASSWORD" -H "$accept" \ -F "source-archive=@$HOME/HUDKit-$version.zip;type=application/zip" \ -F 'metadata={"description": "HUD'\''s renderer in SwiftUI, and the client that calls its tools", "repositoryURLs": ["https://knotless.dev/chadtmiller.com/hud"]};type=application/json' \ "${SWIFT_REGISTRY}hud/HUDKit/$version" echo "published hud.HUDKit $version" fi - name: publish maven on: {refs: [refs/heads/main]} timeout: 30 run: | version=$(cat ~/.version) kind=$(curl -sI "${HUD_MAVEN_URL}place/hud/hudkit/maven-metadata.xml" | tr -d '\r' | sed -n 's/^content-type: *//Ip') if [ -z "$kind" ] || echo "$kind" | grep -qi 'text/html'; then echo "knotless.dev has no Maven repository yet: place.hud:hudkit $version is not published" elif curl -fsI -o /dev/null "${HUD_MAVEN_URL}place/hud/hudkit/$version/hudkit-$version.pom"; then echo "place.hud:hudkit $version is published already" else cd android HUD_MAVEN_USERNAME="$OWNER" HUD_MAVEN_PASSWORD="$RELEASE_PASSWORD" ./gradlew :hudkit:publish --console=plain --no-daemon fi - name: tag on: {refs: [refs/heads/main]} run: | version=$(cat ~/.version) if git ls-remote --exit-code --tags "https://knotless.dev/chadtmiller.com/hud" "refs/tags/v$version" >/dev/null; then echo "v$version is tagged already" else KNOTLESS_IDENTIFIER="$OWNER" KNOTLESS_PASSWORD="$RELEASE_PASSWORD" knotless tag create "$REPO" "v$version" "$KNOTLESS_RUN_SHA" fi