Skip to content

Commit

Permalink
Merge 7597c59 into 1231012
Browse files Browse the repository at this point in the history
  • Loading branch information
k1LoW authored Feb 12, 2023
2 parents 1231012 + 7597c59 commit 34f589a
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,13 @@ jobs:
run: |
go run cmd/gh-setup/main.go --repo k1LoW/gh-setup
gh-setup -v
shell: bash

- name: Run setup as a action (1/2)
uses: ./
with:
repo: k1LoW/tbls

- name: Run setup as a action (2/2)
run: tbls version
shell: bash
36 changes: 36 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: 'Setup asset of Github Releases'
description: 'GitHub Action for gh-setup'
inputs:
github-token:
description: The GitHub token
default: ${{ github.token }}
required: false
repo:
description: "Target repository [OWNER/REPO]"
required: true
bin-dir:
description: "Executable path"
default: ""
required: false
force:
description: "Enable force setup"
default: false
required: false
runs:
using: "composite"
steps:
-
id: install-gh-setup
run: scripts/install-gh-setup.sh
shell: bash
env:
GH_SETUP_GITHUB_TOKEN: ${{ inputs.github-token }}
-
run: scripts/run-gh-setup.sh
shell: bash
env:
GH_SETUP_GITHUB_TOKEN: ${{ inputs.github-token }}
GH_SETUP_REPO: ${{ inputs.repo }}
GH_SETUP_BIN_DIR: ${{ inputs.bin-dir }}
GH_SETUP_FORCE: ${{ inputs.force }}
GH_SETUP_BIN: ${{ steps.install-gh-setup.outputs.bin }}
Empty file modified scripts/entrypoint.sh
100644 → 100755
Empty file.
35 changes: 35 additions & 0 deletions scripts/install-gh-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env bash
set -e

token=${GH_SETUP_GITHUB_TOKEN}
if [ -z "${token}" ]; then
token=${GITHUB_TOKEN}
fi
repo="k1LoW/gh-setup"
tag="$(curl -sL -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${token}" https://api.github.com/repos/${repo}/releases/latest | grep tag_name | awk -F':' '{print $2}' | awk -F'\"' '{print $2}')"
arch="$(uname -m)"

if uname -a | grep Msys > /dev/null; then
if [ $arch = "x86_64" ]; then
exe="gh-setup_${tag}_windows_amd64.exe"
fi
bin="${TEMP}/gh-setup"
elif uname -a | grep Darwin > /dev/null; then
if [ $arch = "x86_64" ]; then
exe="gh-setup_${tag}_darwin_amd64"
elif [ $arch = "arm64" ]; then
exe="gh-setup_${tag}_darwin_arm64"
fi
bin="${TMPDIR}gh-setup"
elif uname -a | grep Linux > /dev/null; then
if [ $arch = "x86_64" ]; then
exe="gh-setup_${tag}_linux_amd64"
fi
bin="/tmp/gh-setup"
fi

# download
curl -sL -o ${bin} https://github.com/k1LoW/gh-setup/releases/download/${tag}/${exe}
chmod +x ${bin}
${bin} -v
echo "bin=${bin}" >> ${GITHUB_OUTPUT}
13 changes: 13 additions & 0 deletions scripts/run-gh-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash
set -e

bin="${GH_SETUP_BIN}"
token=${GH_SETUP_GITHUB_TOKEN}
if [ -z "${token}" ]; then
token=${GITHUB_TOKEN}
fi
repo=${GH_SETUP_REPO}
bindir=${GH_SETUP_BIN_DIR}
force=${GH_SETUP_FORCE}

${bin} --repo ${repo} --bin-dir=${GH_SETUP_BIN_DIR}

0 comments on commit 34f589a

Please sign in to comment.