Windows Wrappers

This commit is contained in:
2026-04-02 21:00:40 +02:00
parent 7c7eb4dcc0
commit 7c8d58586a
3 changed files with 53 additions and 22 deletions
+43 -21
View File
@@ -23,14 +23,16 @@ jobs:
git reset --hard "${TAG_NAME}" git reset --hard "${TAG_NAME}"
git clean -fd git clean -fd
- name: Build sow-toolkit - name: Build sow-toolkit binaries
run: | run: |
set -euo pipefail set -euo pipefail
CHECKOUT_PATH="${CHECKOUT_PATH:-/home/ubuntu/tools-checkout}" CHECKOUT_PATH="${CHECKOUT_PATH:-/home/ubuntu/tools-checkout}"
cd "${CHECKOUT_PATH}" cd "${CHECKOUT_PATH}"
./build-tool.sh mkdir -p tools .cache/go-build
GOCACHE="${PWD}/.cache/go-build" go build -o ./tools/sow-toolkit ./cmd/nwn-tool
GOOS=windows GOARCH=amd64 GOCACHE="${PWD}/.cache/go-build" go build -o ./tools/sow-toolkit.exe ./cmd/nwn-tool
- name: Pack release bundle - name: Pack release bundles
id: pack id: pack
env: env:
TAG_NAME: ${{ github.ref_name }} TAG_NAME: ${{ github.ref_name }}
@@ -38,24 +40,35 @@ jobs:
set -euo pipefail set -euo pipefail
CHECKOUT_PATH="${CHECKOUT_PATH:-/home/ubuntu/tools-checkout}" CHECKOUT_PATH="${CHECKOUT_PATH:-/home/ubuntu/tools-checkout}"
cd "${CHECKOUT_PATH}" cd "${CHECKOUT_PATH}"
binary="tools/sow-toolkit" linux_binary="tools/sow-toolkit"
if [[ ! -x "${binary}" ]]; then windows_binary="tools/sow-toolkit.exe"
echo "Missing built tool: ${binary}" if [[ ! -x "${linux_binary}" ]]; then
echo "Missing built tool: ${linux_binary}"
exit 1 exit 1
fi fi
archive="/tmp/sow-toolkit-linux-amd64-${TAG_NAME}.tar.gz" if [[ ! -f "${windows_binary}" ]]; then
tar -czf "${archive}" -C tools sow-toolkit echo "Missing built tool: ${windows_binary}"
echo "archive=${archive}" >> "$GITHUB_OUTPUT" exit 1
echo "asset_name=sow-toolkit-linux-amd64.tar.gz" >> "$GITHUB_OUTPUT" fi
linux_archive="/tmp/sow-toolkit-linux-amd64-${TAG_NAME}.tar.gz"
windows_archive="/tmp/sow-toolkit-windows-amd64-${TAG_NAME}.zip"
tar -czf "${linux_archive}" -C tools sow-toolkit
zip -j "${windows_archive}" "${windows_binary}"
echo "linux_archive=${linux_archive}" >> "$GITHUB_OUTPUT"
echo "linux_asset_name=sow-toolkit-linux-amd64.tar.gz" >> "$GITHUB_OUTPUT"
echo "windows_archive=${windows_archive}" >> "$GITHUB_OUTPUT"
echo "windows_asset_name=sow-toolkit-windows-amd64.zip" >> "$GITHUB_OUTPUT"
echo "tag=${TAG_NAME}" >> "$GITHUB_OUTPUT" echo "tag=${TAG_NAME}" >> "$GITHUB_OUTPUT"
- name: Create release and upload artifact - name: Create release and upload artifacts
env: env:
GITEA_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITEA_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITEA_SERVER_URL: ${{ github.server_url }} GITEA_SERVER_URL: ${{ github.server_url }}
GITEA_REPO: ${{ github.repository }} GITEA_REPO: ${{ github.repository }}
ARCHIVE: ${{ steps.pack.outputs.archive }} LINUX_ARCHIVE: ${{ steps.pack.outputs.linux_archive }}
ASSET_NAME: ${{ steps.pack.outputs.asset_name }} LINUX_ASSET_NAME: ${{ steps.pack.outputs.linux_asset_name }}
WINDOWS_ARCHIVE: ${{ steps.pack.outputs.windows_archive }}
WINDOWS_ASSET_NAME: ${{ steps.pack.outputs.windows_asset_name }}
TAG_NAME: ${{ steps.pack.outputs.tag }} TAG_NAME: ${{ steps.pack.outputs.tag }}
run: | run: |
set -euo pipefail set -euo pipefail
@@ -85,22 +98,31 @@ jobs:
RELEASE_ID=$(jq -r '.id' "${RESP_FILE}") RELEASE_ID=$(jq -r '.id' "${RESP_FILE}")
fi fi
ASSET_ID=$(jq -r --arg name "${ASSET_NAME}" '.assets[]? | select(.name == $name) | .id' "${RESP_FILE}" | head -n1) for name in "${LINUX_ASSET_NAME}" "${WINDOWS_ASSET_NAME}"; do
if [[ -n "${ASSET_ID}" ]]; then ASSET_ID=$(jq -r --arg name "${name}" '.assets[]? | select(.name == $name) | .id' "${RESP_FILE}" | head -n1)
curl -sS -f "${AUTH[@]}" -X DELETE \ if [[ -n "${ASSET_ID}" ]]; then
"${API}/repos/${OWNER}/${NAME}/releases/${RELEASE_ID}/assets/${ASSET_ID}" curl -sS -f "${AUTH[@]}" -X DELETE \
fi "${API}/repos/${OWNER}/${NAME}/releases/${RELEASE_ID}/assets/${ASSET_ID}"
fi
done
curl -sS -f "${AUTH[@]}" -X POST \ curl -sS -f "${AUTH[@]}" -X POST \
-F "attachment=@${ARCHIVE}" \ -F "attachment=@${LINUX_ARCHIVE}" \
"${API}/repos/${OWNER}/${NAME}/releases/${RELEASE_ID}/assets?name=${ASSET_NAME}" "${API}/repos/${OWNER}/${NAME}/releases/${RELEASE_ID}/assets?name=${LINUX_ASSET_NAME}"
curl -sS -f "${AUTH[@]}" -X POST \
-F "attachment=@${WINDOWS_ARCHIVE}" \
"${API}/repos/${OWNER}/${NAME}/releases/${RELEASE_ID}/assets?name=${WINDOWS_ASSET_NAME}"
- name: Cleanup temporary files - name: Cleanup temporary files
if: always() if: always()
env: env:
TAG_NAME: ${{ github.ref_name }} TAG_NAME: ${{ github.ref_name }}
run: | run: |
rm -f "/tmp/sow-toolkit-linux-amd64-${TAG_NAME}.tar.gz" /tmp/gitea-release.json rm -f \
"/tmp/sow-toolkit-linux-amd64-${TAG_NAME}.tar.gz" \
"/tmp/sow-toolkit-windows-amd64-${TAG_NAME}.zip" \
/tmp/gitea-release.json
- name: Prune old releases (keep latest 1) - name: Prune old releases (keep latest 1)
env: env:
+1
View File
@@ -3,6 +3,7 @@
# Built tool output # Built tool output
/tools/sow-toolkit /tools/sow-toolkit
/tools/sow-toolkit.exe
# OS/editor noise # OS/editor noise
.DS_Store .DS_Store
+9 -1
View File
@@ -41,4 +41,12 @@ During development, sibling repositories can point at `../sow-tools/tools/sow-to
## Release Automation ## Release Automation
This repo publishes a Linux `sow-toolkit` release artifact through Gitea Actions as `sow-toolkit-linux-amd64.tar.gz`. Consumer repos can fetch that binary into their local `tools/` directory with their `install-tool.sh` helper. This repo publishes:
- `sow-toolkit-linux-amd64.tar.gz`
- `sow-toolkit-windows-amd64.zip`
Consumer repos can fetch those binaries into their local `tools/` directory with:
- `install-tool.sh` on Linux/macOS
- `install-tool.ps1` on Windows