Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 100 additions & 0 deletions .github/actions/setup-wfctl/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: Setup wfctl
description: Download and install a specific version of wfctl from GitHub Releases.

inputs:
version:
description: >
wfctl version to install (e.g. v0.52.0). Use "latest" to install the
most recent stable release.
required: false
default: latest

outputs:
version:
description: The resolved wfctl version that was installed.
value: ${{ steps.resolve.outputs.version }}

runs:
using: composite
steps:
- name: Resolve version
id: resolve
shell: bash
run: |
VERSION="${{ inputs.version }}"
if [ "${VERSION}" = "latest" ]; then
VERSION=$(curl -fsSL \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/repos/GoCodeAlone/workflow/releases/latest" \
| jq -r .tag_name)
fi
if [ -z "${VERSION}" ] || [ "${VERSION}" = "null" ]; then
echo "error: could not resolve wfctl version" >&2
exit 1
fi
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"

- name: Download wfctl
shell: bash
run: |
set -euo pipefail
VERSION="${{ steps.resolve.outputs.version }}"
OS="${{ runner.os }}"
ARCH="${{ runner.arch }}"

# Map GitHub Actions runner values to Go GOOS/GOARCH naming
case "${OS}" in
Linux) GOOS=linux ;;
macOS) GOOS=darwin ;;
Windows) GOOS=windows ;;
*)
echo "Unsupported OS: ${OS}" >&2
exit 1
;;
esac
case "${ARCH}" in
X64) GOARCH=amd64 ;;
ARM64) GOARCH=arm64 ;;
Comment thread
intel352 marked this conversation as resolved.
*)
echo "Unsupported architecture: ${ARCH}" >&2
exit 1
;;
esac
if [ "${GOOS}" = "windows" ] && [ "${GOARCH}" = "arm64" ]; then
echo "Unsupported platform: Windows ARM64 wfctl release assets are not published" >&2
exit 1
fi

ASSET="wfctl-${GOOS}-${GOARCH}"
if [ "${GOOS}" = "windows" ]; then
ASSET="${ASSET}.exe"
fi

DOWNLOAD_URL="https://github.com/GoCodeAlone/workflow/releases/download/${VERSION}/${ASSET}"
echo "Downloading wfctl ${VERSION} from ${DOWNLOAD_URL}"

# Install into a directory that is (or will be) on PATH.
# Use RUNNER_TOOL_CACHE when available (hosted runners); fall back to
# a per-run temp dir so the binary is always reachable.
INSTALL_DIR="${RUNNER_TOOL_CACHE:-${RUNNER_TEMP}}/wfctl/${VERSION}"
mkdir -p "${INSTALL_DIR}"

DEST="${INSTALL_DIR}/wfctl"
if [ "${GOOS}" = "windows" ]; then
DEST="${DEST}.exe"
fi

curl -fsSL "${DOWNLOAD_URL}" -o "${DEST}" || {
echo "error: failed to download wfctl ${VERSION} for ${GOOS}/${GOARCH}" >&2
echo " URL: ${DOWNLOAD_URL}" >&2
echo " Verify the release exists: https://github.com/GoCodeAlone/workflow/releases/tag/${VERSION}" >&2
exit 1
}
chmod +x "${DEST}"
echo "${INSTALL_DIR}" >> "$GITHUB_PATH"
echo "Installed wfctl ${VERSION} to ${DEST}"

- name: Verify installation
shell: bash
run: wfctl --version
6 changes: 6 additions & 0 deletions .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ jobs:
GOOS=darwin GOARCH=arm64 go build -ldflags="${LDFLAGS}" -o dist/workflow-darwin-arm64 ./cmd/server
GOOS=windows GOARCH=amd64 go build -ldflags="${LDFLAGS}" -o dist/workflow-windows-amd64.exe ./cmd/server

GOOS=linux GOARCH=amd64 go build -ldflags="${LDFLAGS}" -o dist/wfctl-linux-amd64 ./cmd/wfctl
GOOS=linux GOARCH=arm64 go build -ldflags="${LDFLAGS}" -o dist/wfctl-linux-arm64 ./cmd/wfctl
GOOS=darwin GOARCH=amd64 go build -ldflags="${LDFLAGS}" -o dist/wfctl-darwin-amd64 ./cmd/wfctl
GOOS=darwin GOARCH=arm64 go build -ldflags="${LDFLAGS}" -o dist/wfctl-darwin-arm64 ./cmd/wfctl
GOOS=windows GOARCH=amd64 go build -ldflags="${LDFLAGS}" -o dist/wfctl-windows-amd64.exe ./cmd/wfctl

- name: Package admin UI
run: |
tar -czf "dist/workflow-admin-ui-${VERSION}.tar.gz" -C ui dist
Expand Down
Loading