Compare commits

...

6 Commits

Author SHA1 Message Date
Steven Tang e399af1f1f
fix(build): enable cgo, downgrade release to ubuntu-18.04, add -w -s (#404)
* fix(build): releases with cgo
* build: downgrade to ubuntu-18.04
* build: add -w -s flags
2022-09-08 17:51:26 +10:00
Ferdinand Mütsch 4c1f4ed39b
docs: add eget option [ci skip] 2022-09-07 10:50:26 +02:00
Ferdinand Mütsch 7e5c00d0ae chore: update quick run script (resolve #400) 2022-09-06 22:28:49 +02:00
Ferdinand Mütsch cec2a84e2d
Merge pull request #402 from muety/release-arch
Add more architectures to release binaries (resolve #401)
2022-09-06 22:16:35 +02:00
Steven Tang ffb0b84d78
build: re-enable release steps 2022-09-06 20:51:05 +10:00
Steven Tang 8a7333b899
build: test release architectures 2022-09-06 20:23:47 +10:00
3 changed files with 169 additions and 34 deletions

View File

@ -8,20 +8,30 @@ on:
jobs:
release:
name: 'Build, package and release to GitHub'
strategy:
fail-fast: false
matrix:
platform: [ubuntu-latest, macos-latest, windows-latest]
include:
- platform: ubuntu-latest
alias: linux
- platform: macos-latest
alias: mac
- platform: ubuntu-18.04
GOOS: linux
GOARCH: amd64
CC: gcc
- platform: ubuntu-18.04
package: gcc-aarch64-linux-gnu
GOOS: linux
GOARCH: arm64
CC: aarch64-linux-gnu-gcc
- 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 }}
steps:
- name: Set up Go 1.x
@ -33,6 +43,10 @@ jobs:
- name: Check out code into the Go module directory
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
shell: bash
run: |
@ -40,24 +54,31 @@ jobs:
|| git symbolic-ref -q --short HEAD \
|| git rev-parse --short HEAD) > version.txt 2> /dev/null
- name: Get dependencies
run: go get
- name: Prepare
run: |
mkdir -p dist/ && cd dist/
cp ../config.default.yml config.yml
- 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
if: runner.os == 'Windows'
- name: Compress working folder (Windows PowerShell)
working-directory: ./dist
if: "${{ matrix.GOOS == 'windows' }}"
run: |
cp .\config.default.yml .\config.yml
Compress-Archive -Path .\wakapi.exe, .\config.yml -DestinationPath wakapi_${{ matrix.alias }}_amd64.zip
- name: Compress working folder on Unix
if: runner.os != 'Windows'
Compress-Archive -Path .\wakapi.exe, .\config.yml -DestinationPath wakapi_${{ matrix.GOOS }}_${{ matrix.GOARCH }}.zip
- name: Compress working folder
working-directory: ./dist
if: "${{ matrix.GOOS != 'windows' }}"
run: |
cp config.default.yml config.yml
zip -9 wakapi_${{ matrix.alias }}_amd64.zip wakapi config.yml
zip -9 wakapi_${{ matrix.GOOS }}_${{ matrix.GOARCH }}.zip *
- name: Upload built executable to Release
uses: softprops/action-gh-release@v1
with:
files: wakapi_${{ matrix.alias }}_amd64.zip
files: ./dist/*.zip

View File

@ -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
```
**Alternatively** using [eget](https://github.com/zyedidia/eget):
```bash
$ eget muety/wakapi
```
### 🐳 Option 3: Use Docker
```bash

View File

@ -15,54 +15,163 @@
set -e -u
githubLatestTag() {
finalUrl=$(curl "https://github.com/$1/releases/latest" -s -L -I -o /dev/null -w '%{url_effective}')
printf "%s\n" "${finalUrl##*/}"
latestJSON="$( eval "$http 'https://api.github.com/repos/$1/releases/latest'" 2>/dev/null )" || true
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=''
machine=$(uname -m) # currently, Wakapi builds are only available for AMD64 anyway
machine=$(uname -m)
if [ "${GETWAKAPI_PLATFORM:-x}" != "x" ]; then
platform="$GETWAKAPI_PLATFORM"
else
case "$(uname -s | tr '[:upper:]' '[:lower:]')" in
"linux") platform='linux_amd64' ;;
"msys"*|"cygwin"*|"mingw"*|*"_nt"*|"win"*) platform='win_amd64' ;;
"linux")
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
fi
if [ "x$platform" = "x" ]; then
cat << 'EOM'
if [ "${platform:-x}" = "x" ]; then
cat 1>&2 << 'EOM'
/=====================================\\
| COULD NOT DETECT PLATFORM |
\\=====================================/
Uh oh! We couldn't automatically detect your operating system. You can file a
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
exit 1
else
printf "Detected platform: %s\n" "$platform"
echo "Detected platform: $platform"
fi
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'
printf "Latest Version: %s\n" "$TAG"
printf "Downloading https://github.com/muety/wakapi/releases/download/%s/wakapi_%s.%s\n" "$TAG" "$platform" "$extension"
echo "Latest Version: $TAG"
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
"zip") unzip -j "wakapi.$extension" -d "wakapi-$TAG" ;;
"tar.gz") tar -xvzf "wakapi.$extension" "wakapi-$TAG/wakapi" ;;
esac
mv "wakapi-$TAG/wakapi" ./wakapi
mv "wakapi-$TAG/config.yml" ./config.yml
mv wakapi-$TAG/* .
rm "wakapi.$extension"
rm -rf "wakapi-$TAG"