diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml new file mode 100644 index 0000000..dd3cebe --- /dev/null +++ b/.gitea/workflows/release.yml @@ -0,0 +1,62 @@ +# Builds the Palm app and publishes it as a release when a v* tag is pushed +# (hardware tags are hw-v*, so they don't match). The tag must match the +# VERSION resource in palm-client/resources/visormesh.rcp, e.g. v0.2 for "0.2". +# An annotated tag's message becomes the release notes. +# +# git tag -a v0.2 -m "What changed" && git push origin v0.2 +name: release + +on: + push: + tags: ['v*'] + +jobs: + palm-client: + runs-on: ubuntu-latest + # Bookworm, for the toolchain .debs; Node, for actions/checkout. + container: node:20-bookworm + steps: + - uses: actions/checkout@v4 + + - name: Toolchain + run: sh palm-client/tools/install_toolchain.sh + + - name: Version check + run: | + want="${GITHUB_REF_NAME#v}" + have=$(sed -n 's/^VERSION ID 1 "\(.*\)"/\1/p' palm-client/resources/visormesh.rcp) + if [ "$want" != "$have" ]; then + echo "Tag $GITHUB_REF_NAME doesn't match VERSION \"$have\" in visormesh.rcp"; exit 1 + fi + + - name: Build and test + working-directory: palm-client + run: make && make test + + - name: Release + env: + TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + set -eu + tag="$GITHUB_REF_NAME" + api="$GITHUB_SERVER_URL/api/v1/repos/$GITHUB_REPOSITORY" + mkdir -p dist + cp palm-client/build/visormesh.prc "dist/visormesh-$tag.prc" + (cd dist && sha256sum *.prc > SHA256SUMS) + + git config --global --add safe.directory "$PWD" + git fetch --depth=1 origin "+refs/tags/$tag:refs/tags/$tag" + if [ "$(git cat-file -t "$tag")" = tag ]; then + git for-each-ref "refs/tags/$tag" --format='%(contents:subject)%0a%0a%(contents:body)' > notes.txt + else + : > notes.txt + fi + body=$(python3 -c 'import json,sys; print(json.dumps(sys.stdin.read().strip()))' < notes.txt) + + id=$(curl -fsS -X POST -H "Authorization: token $TOKEN" -H 'Content-Type: application/json' \ + -d "{\"tag_name\":\"$tag\",\"name\":\"VisorMesh $tag\",\"body\":$body}" "$api/releases" | + python3 -c 'import json,sys; print(json.load(sys.stdin)["id"])') + for f in dist/*; do + curl -fsS -X POST -H "Authorization: token $TOKEN" \ + -F "attachment=@$f" "$api/releases/$id/assets?name=$(basename "$f")" >/dev/null + done diff --git a/palm-client/Dockerfile b/palm-client/Dockerfile index 30ae7de..2b57071 100644 --- a/palm-client/Dockerfile +++ b/palm-client/Dockerfile @@ -1,22 +1,10 @@ # Palm OS 68k build environment: prc-tools-remix (m68k-palmos-gcc), PilRC, # and the Palm OS SDKs. The packages are amd64-only; on Apple Silicon Docker # runs this under emulation (build/run with --platform linux/amd64), which is fine for builds this small. +# The versions are pinned in tools/install_toolchain.sh, which the release workflow also runs. FROM debian:bookworm-slim -ARG PRC_TOOLS_VER=2.3.6 -ARG PILRC_TAG=2.3.91 -ARG PILRC_VER=3.2.91 -ARG PALM_SDK_COMMIT=1fa22066ca0f8b74949c14dd1d626294145d1c09 - -RUN apt-get update \ - && apt-get install -y --no-install-recommends ca-certificates curl unzip make gcc libc6-dev python3-minimal \ - && curl -fsSLo /tmp/prc.deb https://github.com/jichu4n/prc-tools-remix/releases/download/v${PRC_TOOLS_VER}/prc-tools-remix_${PRC_TOOLS_VER}.bookworm_amd64.deb \ - && curl -fsSLo /tmp/pilrc.deb https://github.com/jichu4n/pilrc/releases/download/${PILRC_TAG}/pilrc_${PILRC_VER}.bookworm_amd64.deb \ - && apt-get install -y --no-install-recommends /tmp/prc.deb /tmp/pilrc.deb \ - && curl -fsSLo /tmp/sdk.zip https://github.com/jichu4n/palm-os-sdk/archive/${PALM_SDK_COMMIT}.zip \ - && unzip -q /tmp/sdk.zip -d /tmp \ - && mv /tmp/palm-os-sdk-${PALM_SDK_COMMIT} /opt/palmdev \ - && palmdev-prep -d sdk-3.5 \ - && rm -rf /tmp/*.deb /tmp/sdk.zip /var/lib/apt/lists/* +COPY tools/install_toolchain.sh /tmp/install_toolchain.sh +RUN sh /tmp/install_toolchain.sh && rm /tmp/install_toolchain.sh WORKDIR /src diff --git a/palm-client/README.md b/palm-client/README.md index 17c9ed5..92c88ba 100644 --- a/palm-client/README.md +++ b/palm-client/README.md @@ -11,7 +11,7 @@ make test # host-side tests for the protocol framing If `m68k-palmos-gcc` isn't installed, `make` builds and runs the `visormesh-palm` Docker image (see `Dockerfile`) and does the build inside it. The first run takes a minute or two. The image is amd64-only, so on Apple Silicon it runs under emulation. That's fine for builds this small. -The toolchain versions and the palm-os-sdk commit are pinned in the `Dockerfile`. +The toolchain versions and the palm-os-sdk commit are pinned in `tools/install_toolchain.sh`, which the `Dockerfile` and the release workflow both run. Your editor's C checker can't see the Palm SDK headers, since they only exist inside the image. Errors like `'PalmOS.h' file not found` there are expected and don't affect the build. diff --git a/palm-client/tools/install_toolchain.sh b/palm-client/tools/install_toolchain.sh new file mode 100755 index 0000000..76449fb --- /dev/null +++ b/palm-client/tools/install_toolchain.sh @@ -0,0 +1,21 @@ +#!/bin/sh +# Installs the Palm OS 68k toolchain on Debian bookworm (amd64): prc-tools-remix, +# PilRC and the Palm OS SDKs. Shared by the Dockerfile and the release workflow +# (.gitea/workflows/release.yml), so both build with the same pinned versions. +set -eu + +PRC_TOOLS_VER=2.3.6 +PILRC_TAG=2.3.91 +PILRC_VER=3.2.91 +PALM_SDK_COMMIT=1fa22066ca0f8b74949c14dd1d626294145d1c09 + +apt-get update +apt-get install -y --no-install-recommends ca-certificates curl unzip make gcc libc6-dev python3-minimal +curl -fsSLo /tmp/prc.deb https://github.com/jichu4n/prc-tools-remix/releases/download/v${PRC_TOOLS_VER}/prc-tools-remix_${PRC_TOOLS_VER}.bookworm_amd64.deb +curl -fsSLo /tmp/pilrc.deb https://github.com/jichu4n/pilrc/releases/download/${PILRC_TAG}/pilrc_${PILRC_VER}.bookworm_amd64.deb +apt-get install -y --no-install-recommends /tmp/prc.deb /tmp/pilrc.deb +curl -fsSLo /tmp/sdk.zip https://github.com/jichu4n/palm-os-sdk/archive/${PALM_SDK_COMMIT}.zip +unzip -q /tmp/sdk.zip -d /tmp +mv /tmp/palm-os-sdk-${PALM_SDK_COMMIT} /opt/palmdev +palmdev-prep -d sdk-3.5 +rm -rf /tmp/*.deb /tmp/sdk.zip /var/lib/apt/lists/*