Skip to content

Commit

Permalink
Add Windows to GitHub workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Yvee1 committed Dec 17, 2023
1 parent 7f4a0ae commit 98248a8
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 11 deletions.
37 changes: 27 additions & 10 deletions .github/scripts/attach-binary.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,36 @@ else
if [ "$RUNNER_OS" = "Linux" ]
then
ARCH="linux"
elif [ "$RUNNER_OS" = "Windows" ]
then
ARCH="windows"
else
ARCH="osx"
fi
OWNER="$(echo "$GITHUB_REPOSITORY" | cut -f1 -d/)"
REPO="$(echo "$GITHUB_REPOSITORY" | cut -f2 -d/)"
BIN="$(stack path --local-install-root)/bin/$REPO"
BUNDLE_NAME="$REPO-$RELEASE_VERSION-$ARCH.tar.gz"
cp "$BIN" "./$REPO"
chmod +x "./$REPO"
tar -czf "$BUNDLE_NAME" "$REPO"
echo "SHA256:"
shasum -a 256 "$BUNDLE_NAME"
ls $HOME/.local/bin/
echo $PATH
$HOME/.local/bin/ghr -t "$GITHUB_TOKEN" -u "$OWNER" -r "$REPO" --replace "$(git describe --tags)" "$BUNDLE_NAME"
if [ "$RUNNER_OS" = "Windows" ]
then
BIN="$(stack path --local-install-root)/bin/$REPO.exe"
cp "$BIN" "./$REPO.exe"
chmod +x "./$REPO.exe"
BUNDLE_NAME="$REPO-$RELEASE_VERSION-$ARCH.zip"
zip "$BUNDLE_NAME" "$REPO.exe"
echo "SHA256:"
shasum -a 256 "$BUNDLE_NAME"
ls $HOME/ghr/
echo $PATH
ghr -t "$GITHUB_TOKEN" -u "$OWNER" -r "$REPO" --replace "$(git describe --tags)" "$BUNDLE_NAME"
else
BIN="$(stack path --local-install-root)/bin/$REPO"
BUNDLE_NAME="$REPO-$RELEASE_VERSION-$ARCH.tar.gz"
cp "$BIN" "./$REPO"
chmod +x "./$REPO"
tar -czf "$BUNDLE_NAME" "$REPO"
echo "SHA256:"
shasum -a 256 "$BUNDLE_NAME"
ls $HOME/.local/bin/
echo $PATH
$HOME/.local/bin/ghr -t "$GITHUB_TOKEN" -u "$OWNER" -r "$REPO" --replace "$(git describe --tags)" "$BUNDLE_NAME"
fi
fi
12 changes: 12 additions & 0 deletions .github/scripts/install-ghr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@ else
tar -x -f ghr.tar --strip-components 1
mv ghr "$HOME/.local/bin/"
rm ghr.tar
elif [ "$RUNNER_OS" = "Windows"]
then
ARCH="windows"
URL="https://github.com/tcnksm/ghr/releases/download/v0.14.0/ghr_v0.14.0_${ARCH}_amd64.zip"
curl -L ${URL} > ghr.zip
unzip ghr.zip
GHR_DIR="ghr_v0.14.0_${ARCH}_amd64"
mkdir "$HOME/ghr"
mv $GHR_DIR/ghr.exe "$HOME/ghr"
export PATH=$PATH:"$HOME/ghr"
rm ghr.zip
rm -r $GHR_DIR
else
ARCH="darwin"
URL="https://github.com/tcnksm/ghr/releases/download/v0.14.0/ghr_v0.14.0_${ARCH}_amd64.zip"
Expand Down
12 changes: 11 additions & 1 deletion .github/scripts/install-stack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ else
if [ "$RUNNER_OS" = "Linux" ]
then
ARCH="linux"
elif [ "$RUNNER_OS" = "Windows" ]
then
ARCH="windows"
else
ARCH="osx"
fi
Expand All @@ -16,7 +19,14 @@ else
gunzip stack.tar.gz
tar -x -f stack.tar --strip-components 1
mkdir -p "$HOME/.local/bin"
mv stack "$HOME/.local/bin/"
if [ "$RUNNER_OS" = "Windows" ]
then
mkdir "$HOME/stack"
mv stack.exe "$HOME/stack"
export PATH=$PATH:"$HOME/stack"
else
mv stack "$HOME/.local/bin/"
fi
rm stack.tar
fi

Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@ on: [push]
jobs:
build:
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
Expand Down

0 comments on commit 98248a8

Please sign in to comment.