-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
88 lines (88 loc) · 3.36 KB
/
action.yml
File metadata and controls
88 lines (88 loc) · 3.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
name: 'Setup wfctl'
description: 'Install the wfctl CLI tool for workflow engine operations'
inputs:
version:
description: 'wfctl version to install (e.g., "v0.3.51", "latest")'
required: false
default: 'latest'
token:
description: 'GitHub token for downloading releases'
required: false
default: ${{ github.token }}
install-dir:
description: 'Directory to install wfctl into. When set, sudo is not used and the directory is appended to GITHUB_PATH. Defaults to /usr/local/bin (existing behavior).'
required: false
default: ''
runs:
using: 'composite'
steps:
- name: Determine version
id: version
shell: bash
run: |
if [ "${{ inputs.version }}" = "latest" ]; then
VERSION=$(curl -s https://api.github.com/repos/GoCodeAlone/workflow/releases/latest | grep '"tag_name"' | sed 's/.*"tag_name": "//;s/".*//')
else
VERSION="${{ inputs.version }}"
fi
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
- name: Determine OS and arch
id: platform
shell: bash
run: |
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
ARCH=$(uname -m)
case "$ARCH" in
x86_64) ARCH="amd64" ;;
aarch64|arm64) ARCH="arm64" ;;
esac
echo "os=${OS}" >> "$GITHUB_OUTPUT"
echo "arch=${ARCH}" >> "$GITHUB_OUTPUT"
- name: Resolve install directory
id: install
shell: bash
run: |
if [ -n "${{ inputs.install-dir }}" ]; then
INSTALL_DIR="${{ inputs.install-dir }}"
mkdir -p "${INSTALL_DIR}"
echo "install_dir=${INSTALL_DIR}" >> "$GITHUB_OUTPUT"
echo "use_sudo=false" >> "$GITHUB_OUTPUT"
else
echo "install_dir=/usr/local/bin" >> "$GITHUB_OUTPUT"
echo "use_sudo=true" >> "$GITHUB_OUTPUT"
fi
- name: Cache wfctl
uses: actions/cache@v5
id: cache
with:
path: ${{ steps.install.outputs.install_dir }}/wfctl
key: wfctl-${{ steps.version.outputs.version }}-${{ steps.platform.outputs.os }}-${{ steps.platform.outputs.arch }}
- name: Download wfctl
if: steps.cache.outputs.cache-hit != 'true'
shell: bash
env:
GH_TOKEN: ${{ inputs.token }}
run: |
VERSION="${{ steps.version.outputs.version }}"
OS="${{ steps.platform.outputs.os }}"
ARCH="${{ steps.platform.outputs.arch }}"
INSTALL_DIR="${{ steps.install.outputs.install_dir }}"
# Release assets use hyphen separators and are bare binaries (no .tar.gz)
ASSET="wfctl-${OS}-${ARCH}"
URL="https://github.com/GoCodeAlone/workflow/releases/download/${VERSION}/${ASSET}"
echo "Downloading wfctl ${VERSION} for ${OS}/${ARCH}..."
if [ "${{ steps.install.outputs.use_sudo }}" = "true" ]; then
curl -sL -H "Authorization: token ${GH_TOKEN}" "${URL}" -o /tmp/wfctl
sudo mv /tmp/wfctl "${INSTALL_DIR}/wfctl"
sudo chmod +x "${INSTALL_DIR}/wfctl"
else
curl -sL -H "Authorization: token ${GH_TOKEN}" "${URL}" -o "${INSTALL_DIR}/wfctl"
chmod +x "${INSTALL_DIR}/wfctl"
fi
- name: Add install directory to PATH
if: steps.install.outputs.use_sudo == 'false'
shell: bash
run: echo "${{ steps.install.outputs.install_dir }}" >> "$GITHUB_PATH"
- name: Verify installation
shell: bash
run: wfctl version