mirror of https://github.com/muety/wakapi.git
Compare commits
6 Commits
dd3b9c9b9c
...
e399af1f1f
Author | SHA1 | Date |
---|---|---|
Steven Tang | e399af1f1f | |
Ferdinand Mütsch | 4c1f4ed39b | |
Ferdinand Mütsch | 7e5c00d0ae | |
Ferdinand Mütsch | cec2a84e2d | |
Steven Tang | ffb0b84d78 | |
Steven Tang | 8a7333b899 |
|
@ -8,20 +8,30 @@ on:
|
||||||
jobs:
|
jobs:
|
||||||
release:
|
release:
|
||||||
name: 'Build, package and release to GitHub'
|
name: 'Build, package and release to GitHub'
|
||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
platform: [ubuntu-latest, macos-latest, windows-latest]
|
|
||||||
include:
|
include:
|
||||||
- platform: ubuntu-latest
|
- platform: ubuntu-18.04
|
||||||
alias: linux
|
GOOS: linux
|
||||||
- platform: macos-latest
|
GOARCH: amd64
|
||||||
alias: mac
|
CC: gcc
|
||||||
|
- platform: ubuntu-18.04
|
||||||
|
package: gcc-aarch64-linux-gnu
|
||||||
|
GOOS: linux
|
||||||
|
GOARCH: arm64
|
||||||
|
CC: aarch64-linux-gnu-gcc
|
||||||
- platform: windows-latest
|
- platform: windows-latest
|
||||||
alias: win
|
GOOS: windows
|
||||||
|
GOARCH: amd64
|
||||||
|
- platform: macos-latest
|
||||||
|
GOOS: darwin
|
||||||
|
GOARCH: amd64
|
||||||
|
- platform: macos-latest
|
||||||
|
GOOS: darwin
|
||||||
|
GOARCH: arm64
|
||||||
runs-on: ${{ matrix.platform }}
|
runs-on: ${{ matrix.platform }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
|
||||||
- name: Set up Go 1.x
|
- name: Set up Go 1.x
|
||||||
|
@ -33,6 +43,10 @@ jobs:
|
||||||
- name: Check out code into the Go module directory
|
- name: Check out code into the Go module directory
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Install gcc
|
||||||
|
if: "${{ matrix.package != '' }}"
|
||||||
|
run: sudo apt-get update && sudo apt-get -y install ${{ matrix.package }}
|
||||||
|
|
||||||
- name: Set version
|
- name: Set version
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
|
@ -40,24 +54,31 @@ jobs:
|
||||||
|| git symbolic-ref -q --short HEAD \
|
|| git symbolic-ref -q --short HEAD \
|
||||||
|| git rev-parse --short HEAD) > version.txt 2> /dev/null
|
|| git rev-parse --short HEAD) > version.txt 2> /dev/null
|
||||||
|
|
||||||
- name: Get dependencies
|
- name: Prepare
|
||||||
run: go get
|
run: |
|
||||||
|
mkdir -p dist/ && cd dist/
|
||||||
|
cp ../config.default.yml config.yml
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: go build -v .
|
working-directory: ./dist
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
GOOS=${{ matrix.GOOS }} GOARCH=${{ matrix.GOARCH }} \
|
||||||
|
CC=${{ matrix.CC }} CGO_ENABLED=1 go build -v -ldflags '-w -s' ../
|
||||||
|
|
||||||
- name: Compress working folder on Windows
|
- name: Compress working folder (Windows PowerShell)
|
||||||
if: runner.os == 'Windows'
|
working-directory: ./dist
|
||||||
|
if: "${{ matrix.GOOS == 'windows' }}"
|
||||||
run: |
|
run: |
|
||||||
cp .\config.default.yml .\config.yml
|
Compress-Archive -Path .\wakapi.exe, .\config.yml -DestinationPath wakapi_${{ matrix.GOOS }}_${{ matrix.GOARCH }}.zip
|
||||||
Compress-Archive -Path .\wakapi.exe, .\config.yml -DestinationPath wakapi_${{ matrix.alias }}_amd64.zip
|
|
||||||
- name: Compress working folder on Unix
|
- name: Compress working folder
|
||||||
if: runner.os != 'Windows'
|
working-directory: ./dist
|
||||||
|
if: "${{ matrix.GOOS != 'windows' }}"
|
||||||
run: |
|
run: |
|
||||||
cp config.default.yml config.yml
|
zip -9 wakapi_${{ matrix.GOOS }}_${{ matrix.GOARCH }}.zip *
|
||||||
zip -9 wakapi_${{ matrix.alias }}_amd64.zip wakapi config.yml
|
|
||||||
|
|
||||||
- name: Upload built executable to Release
|
- name: Upload built executable to Release
|
||||||
uses: softprops/action-gh-release@v1
|
uses: softprops/action-gh-release@v1
|
||||||
with:
|
with:
|
||||||
files: wakapi_${{ matrix.alias }}_amd64.zip
|
files: ./dist/*.zip
|
||||||
|
|
|
@ -66,6 +66,11 @@ If you want to try out a free, hosted cloud service, all you need to do is creat
|
||||||
$ curl -L https://wakapi.dev/get | bash
|
$ curl -L https://wakapi.dev/get | bash
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**Alternatively** using [eget](https://github.com/zyedidia/eget):
|
||||||
|
```bash
|
||||||
|
$ eget muety/wakapi
|
||||||
|
```
|
||||||
|
|
||||||
### 🐳 Option 3: Use Docker
|
### 🐳 Option 3: Use Docker
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|
137
scripts/get.sh
137
scripts/get.sh
|
@ -15,54 +15,163 @@
|
||||||
set -e -u
|
set -e -u
|
||||||
|
|
||||||
githubLatestTag() {
|
githubLatestTag() {
|
||||||
finalUrl=$(curl "https://github.com/$1/releases/latest" -s -L -I -o /dev/null -w '%{url_effective}')
|
latestJSON="$( eval "$http 'https://api.github.com/repos/$1/releases/latest'" 2>/dev/null )" || true
|
||||||
printf "%s\n" "${finalUrl##*/}"
|
|
||||||
|
versionNumber=''
|
||||||
|
if ! echo "$latestJSON" | grep 'API rate limit exceeded' >/dev/null 2>&1 ; then
|
||||||
|
if ! versionNumber="$( echo "$latestJSON" | grep -oEm1 '[0-9]+[.][0-9]+[.][0-9]+' - 2>/dev/null )" ; then
|
||||||
|
versionNumber=''
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${versionNumber:-x}" = "x" ] ; then
|
||||||
|
# Try to fallback to previous latest version detection method if curl is available
|
||||||
|
if command -v curl >/dev/null 2>&1 ; then
|
||||||
|
if finalUrl="$( curl "https://github.com/$1/releases/latest" -s -L -I -o /dev/null -w '%{url_effective}' 2>/dev/null )" ; then
|
||||||
|
trimmedVers="${finalUrl##*v}"
|
||||||
|
if [ "${trimmedVers:-x}" != "x" ] ; then
|
||||||
|
echo "$trimmedVers"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
cat 1>&2 << 'EOA'
|
||||||
|
/=====================================\\
|
||||||
|
| FAILED TO HTTP DOWNLOAD FILE |
|
||||||
|
\\=====================================/
|
||||||
|
|
||||||
|
Uh oh! We couldn't download needed internet resources for you. Perhaps you are
|
||||||
|
offline, your DNS servers are not set up properly, your internet plan doesn't
|
||||||
|
include GitHub, or the GitHub servers are down?
|
||||||
|
|
||||||
|
EOA
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "$versionNumber"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if [ "${GETMICRO_HTTP:-x}" != "x" ]; then
|
||||||
|
http="$GETMICRO_HTTP"
|
||||||
|
elif command -v curl >/dev/null 2>&1 ; then
|
||||||
|
http="curl -L"
|
||||||
|
elif command -v wget >/dev/null 2>&1 ; then
|
||||||
|
http="wget -O-"
|
||||||
|
else
|
||||||
|
cat 1>&2 << 'EOA'
|
||||||
|
/=====================================\\
|
||||||
|
| COULD NOT FIND HTTP PROGRAM |
|
||||||
|
\\=====================================/
|
||||||
|
|
||||||
|
Uh oh! We couldn't find either curl or wget installed on your system.
|
||||||
|
|
||||||
|
To continue with installation, you have two options:
|
||||||
|
|
||||||
|
A. Install either wget or curl on your system. You may need to run `hash -r`.
|
||||||
|
|
||||||
|
B. Define GETMICRO_HTTP to be a command (with arguments deliminated by spaces)
|
||||||
|
that both follows HTTP redirects AND prints the fetched content to stdout.
|
||||||
|
|
||||||
|
For examples of option B, this script uses the below values for wget and curl:
|
||||||
|
|
||||||
|
$ curl https://wakapi.dev/get | GETMICRO_HTTP="curl -L" sh
|
||||||
|
|
||||||
|
$ wget -O- https://wakapi.dev/get | GETMICRO_HTTP="wget -O-" sh
|
||||||
|
|
||||||
|
EOA
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
platform=''
|
platform=''
|
||||||
machine=$(uname -m) # currently, Wakapi builds are only available for AMD64 anyway
|
machine=$(uname -m)
|
||||||
|
|
||||||
if [ "${GETWAKAPI_PLATFORM:-x}" != "x" ]; then
|
if [ "${GETWAKAPI_PLATFORM:-x}" != "x" ]; then
|
||||||
platform="$GETWAKAPI_PLATFORM"
|
platform="$GETWAKAPI_PLATFORM"
|
||||||
else
|
else
|
||||||
case "$(uname -s | tr '[:upper:]' '[:lower:]')" in
|
case "$(uname -s | tr '[:upper:]' '[:lower:]')" in
|
||||||
"linux") platform='linux_amd64' ;;
|
"linux")
|
||||||
"msys"*|"cygwin"*|"mingw"*|*"_nt"*|"win"*) platform='win_amd64' ;;
|
case "$machine" in
|
||||||
|
"arm64"* | "aarch64"* ) platform='linux_arm64' ;;
|
||||||
|
*"64") platform='linux_amd64' ;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
"darwin")
|
||||||
|
case "$machine" in
|
||||||
|
"arm64"* | "aarch64"* ) platform='darwin_arm64' ;;
|
||||||
|
*"64") platform='darwin_amd64' ;;
|
||||||
|
esac;;
|
||||||
|
"msys"*|"cygwin"*|"mingw"*|*"_nt"*|"win"*)
|
||||||
|
case "$machine" in
|
||||||
|
"arm64"* | "aarch64"* ) platform='win_arm64' ;;
|
||||||
|
*"64") platform='win_amd64' ;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "x$platform" = "x" ]; then
|
if [ "${platform:-x}" = "x" ]; then
|
||||||
cat << 'EOM'
|
cat 1>&2 << 'EOM'
|
||||||
/=====================================\\
|
/=====================================\\
|
||||||
| COULD NOT DETECT PLATFORM |
|
| COULD NOT DETECT PLATFORM |
|
||||||
\\=====================================/
|
\\=====================================/
|
||||||
|
|
||||||
Uh oh! We couldn't automatically detect your operating system. You can file a
|
Uh oh! We couldn't automatically detect your operating system. You can file a
|
||||||
bug here: https://github.com/muety/wakapi
|
bug here: https://github.com/muety/wakapi
|
||||||
|
|
||||||
|
To continue with installation, please choose from one of the following values:
|
||||||
|
|
||||||
|
- win_amd64
|
||||||
|
- darwin_amd64
|
||||||
|
- linux_amd64
|
||||||
|
|
||||||
|
Export your selection as the GETWAKAPI_PLATFORM environment variable, and then
|
||||||
|
re-run this script.
|
||||||
|
|
||||||
|
For example:
|
||||||
|
|
||||||
|
$ curl https://getmic.ro | GETWAKAPI_PLATFORM=linux_amd64 sh
|
||||||
|
|
||||||
EOM
|
EOM
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
printf "Detected platform: %s\n" "$platform"
|
echo "Detected platform: $platform"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
TAG=$(githubLatestTag muety/wakapi)
|
TAG=$(githubLatestTag muety/wakapi)
|
||||||
|
|
||||||
printf "Tag: %s" "$TAG"
|
if command -v grep >/dev/null 2>&1 ; then
|
||||||
|
if ! echo "v$TAG" | grep -E '^v[0-9]+[.][0-9]+[.][0-9]+$' >/dev/null 2>&1 ; then
|
||||||
|
cat 1>&2 << 'EOM'
|
||||||
|
/=====================================\\
|
||||||
|
| INVALID TAG RECIEVED |
|
||||||
|
\\=====================================/
|
||||||
|
|
||||||
|
Uh oh! We recieved an invalid tag and cannot be sure that the tag will not break
|
||||||
|
this script.
|
||||||
|
|
||||||
|
Please open an issue on GitHub at https://github.com/muety/wakapi with
|
||||||
|
the invalid tag included:
|
||||||
|
|
||||||
|
EOM
|
||||||
|
echo "> $TAG" 1>&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
extension='zip'
|
extension='zip'
|
||||||
|
|
||||||
printf "Latest Version: %s\n" "$TAG"
|
echo "Latest Version: $TAG"
|
||||||
printf "Downloading https://github.com/muety/wakapi/releases/download/%s/wakapi_%s.%s\n" "$TAG" "$platform" "$extension"
|
echo "Downloading https://github.com/muety/wakapi/releases/download/$TAG/wakapi_$platform.$extension"
|
||||||
|
|
||||||
curl -L "https://github.com/muety/wakapi/releases/download/$TAG/wakapi_$platform.$extension" > "wakapi.$extension"
|
eval "$http 'https://github.com/muety/wakapi/releases/download/$TAG/wakapi_$platform.$extension'" > "wakapi.$extension"
|
||||||
|
|
||||||
case "$extension" in
|
case "$extension" in
|
||||||
"zip") unzip -j "wakapi.$extension" -d "wakapi-$TAG" ;;
|
"zip") unzip -j "wakapi.$extension" -d "wakapi-$TAG" ;;
|
||||||
"tar.gz") tar -xvzf "wakapi.$extension" "wakapi-$TAG/wakapi" ;;
|
"tar.gz") tar -xvzf "wakapi.$extension" "wakapi-$TAG/wakapi" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
mv "wakapi-$TAG/wakapi" ./wakapi
|
mv wakapi-$TAG/* .
|
||||||
mv "wakapi-$TAG/config.yml" ./config.yml
|
|
||||||
|
|
||||||
rm "wakapi.$extension"
|
rm "wakapi.$extension"
|
||||||
rm -rf "wakapi-$TAG"
|
rm -rf "wakapi-$TAG"
|
||||||
|
|
Loading…
Reference in New Issue