diff --git a/.gitea/workflows/release-tool.yml b/.gitea/workflows/release-tool.yml index 51bf956..69c9fd3 100644 --- a/.gitea/workflows/release-tool.yml +++ b/.gitea/workflows/release-tool.yml @@ -23,14 +23,16 @@ jobs: git reset --hard "${TAG_NAME}" git clean -fd - - name: Build sow-toolkit + - name: Build sow-toolkit binaries run: | set -euo pipefail CHECKOUT_PATH="${CHECKOUT_PATH:-/home/ubuntu/tools-checkout}" 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 env: TAG_NAME: ${{ github.ref_name }} @@ -38,24 +40,35 @@ jobs: set -euo pipefail CHECKOUT_PATH="${CHECKOUT_PATH:-/home/ubuntu/tools-checkout}" cd "${CHECKOUT_PATH}" - binary="tools/sow-toolkit" - if [[ ! -x "${binary}" ]]; then - echo "Missing built tool: ${binary}" + linux_binary="tools/sow-toolkit" + windows_binary="tools/sow-toolkit.exe" + if [[ ! -x "${linux_binary}" ]]; then + echo "Missing built tool: ${linux_binary}" exit 1 fi - archive="/tmp/sow-toolkit-linux-amd64-${TAG_NAME}.tar.gz" - tar -czf "${archive}" -C tools sow-toolkit - echo "archive=${archive}" >> "$GITHUB_OUTPUT" - echo "asset_name=sow-toolkit-linux-amd64.tar.gz" >> "$GITHUB_OUTPUT" + if [[ ! -f "${windows_binary}" ]]; then + echo "Missing built tool: ${windows_binary}" + exit 1 + 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" - - name: Create release and upload artifact + - name: Create release and upload artifacts env: GITEA_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITEA_SERVER_URL: ${{ github.server_url }} GITEA_REPO: ${{ github.repository }} - ARCHIVE: ${{ steps.pack.outputs.archive }} - ASSET_NAME: ${{ steps.pack.outputs.asset_name }} + LINUX_ARCHIVE: ${{ steps.pack.outputs.linux_archive }} + 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 }} run: | set -euo pipefail @@ -85,22 +98,31 @@ jobs: RELEASE_ID=$(jq -r '.id' "${RESP_FILE}") fi - ASSET_ID=$(jq -r --arg name "${ASSET_NAME}" '.assets[]? | select(.name == $name) | .id' "${RESP_FILE}" | head -n1) - if [[ -n "${ASSET_ID}" ]]; then - curl -sS -f "${AUTH[@]}" -X DELETE \ - "${API}/repos/${OWNER}/${NAME}/releases/${RELEASE_ID}/assets/${ASSET_ID}" - fi + for name in "${LINUX_ASSET_NAME}" "${WINDOWS_ASSET_NAME}"; do + ASSET_ID=$(jq -r --arg name "${name}" '.assets[]? | select(.name == $name) | .id' "${RESP_FILE}" | head -n1) + if [[ -n "${ASSET_ID}" ]]; then + curl -sS -f "${AUTH[@]}" -X DELETE \ + "${API}/repos/${OWNER}/${NAME}/releases/${RELEASE_ID}/assets/${ASSET_ID}" + fi + done curl -sS -f "${AUTH[@]}" -X POST \ - -F "attachment=@${ARCHIVE}" \ - "${API}/repos/${OWNER}/${NAME}/releases/${RELEASE_ID}/assets?name=${ASSET_NAME}" + -F "attachment=@${LINUX_ARCHIVE}" \ + "${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 if: always() env: TAG_NAME: ${{ github.ref_name }} 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) env: diff --git a/.gitignore b/.gitignore index 58fa116..86ee85c 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ # Built tool output /tools/sow-toolkit +/tools/sow-toolkit.exe # OS/editor noise .DS_Store diff --git a/README.md b/README.md index eeba58e..70e9423 100644 --- a/README.md +++ b/README.md @@ -41,4 +41,12 @@ During development, sibling repositories can point at `../sow-tools/tools/sow-to ## 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