Skip to content

Commit

Permalink
Chore: 支持 termux 打包
Browse files Browse the repository at this point in the history
  • Loading branch information
dzpao committed Jan 29, 2020
1 parent a876b8f commit 22dade0
Show file tree
Hide file tree
Showing 7 changed files with 142 additions and 5 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ jobs:
runs-on: ubuntu-latest
steps:

- name: Set up Go 1.12
- name: Set up Go
uses: actions/setup-go@v1
with:
go-version: 1.13.6
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v1
Expand Down
25 changes: 23 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,41 @@ jobs:
name: Release on GitHub
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v1
with:
go-version: 1.13.6

- name: Check out code
uses: actions/checkout@v1

- name: Set env via git describe
run: echo ::set-env name=GIT_DESCRIBE::$(git describe --always --tags --dirty)

- name: Validates Goreleaser config
uses: docker://goreleaser/goreleaser:latest
uses: goreleaser/goreleaser-action@v1
with:
args: check

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}

- name: Install termux-create-package
run: pip3 install termux-create-package

- name: Install jq
run: sudo apt-get install jq

- name: Create release on GitHub
uses: docker://goreleaser/goreleaser:latest
uses: goreleaser/goreleaser-action@v1
with:
args: release
env:
GITHUB_TOKEN: ${{secrets.GORELEASER_GITHUB_TOKEN}}

- name: Upload termux package to GitHub
run: bash build/termux-build.sh
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
1 change: 0 additions & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ brews:
email: goreleaser@carlosbecker.com
description: "一个用 Go 语言开发的 MUD 客户端"
homepage: "https://github.com/dzpao/go-mud"

skip_upload: false
install: |
bin.install "go-mud"
15 changes: 15 additions & 0 deletions build/termux-armv6.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "go-mud",
"version": "VAR-VERSION",
"homepage": "https://github.com/dzpao/go-mud",
"maintainer": "@dzpao",
"description": "A mud client written in Go",
"arch": "arm",
"depends": [],
"files" :{
"README.md": "README.md",
"LICENSE": "LICENSE",
"dist/CHANGELOG.md": "CHANGELOG.md",
"dist/go-mud_linux_arm_6/go-mud": "bin/go-mud"
}
}
15 changes: 15 additions & 0 deletions build/termux-armv7.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "go-mud",
"version": "VAR-VERSION",
"homepage": "https://github.com/dzpao/go-mud",
"maintainer": "@dzpao",
"description": "A mud client written in Go",
"arch": "arm",
"depends": [],
"files" :{
"README.md": "README.md",
"LICENSE": "LICENSE",
"dist/CHANGELOG.md": "CHANGELOG.md",
"dist/go-mud_linux_arm_7/go-mud": "bin/go-mud"
}
}
15 changes: 15 additions & 0 deletions build/termux-armv8.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "go-mud",
"version": "VAR-VERSION",
"homepage": "https://github.com/dzpao/go-mud",
"maintainer": "@dzpao",
"description": "A mud client written in Go",
"arch": "aarch64",
"depends": [],
"files" :{
"README.md": "README.md",
"LICENSE": "LICENSE",
"dist/CHANGELOG.md": "CHANGELOG.md",
"dist/go-mud_linux_arm64/go-mud": "bin/go-mud"
}
}
73 changes: 73 additions & 0 deletions build/termux-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/bin/bash

PATH=$PATH:~/.local/bin
export PATH

DEB_VERSION=$(echo $GIT_DESCRIBE | cut -c2-)

APP_NAME=go-mud

sed -i 's/VAR-VERSION/'$DEB_VERSION'/' build/termux-armv6.json
termux-create-package build/termux-armv6.json
test -f ${APP_NAME}_${DEB_VERSION}_arm.deb || exit 1
mv ${APP_NAME}_*_arm.deb dist/${APP_NAME}_v${DEB_VERSION}_Termux_ARMv6.deb

sed -i 's/VAR-VERSION/'$DEB_VERSION'/' build/termux-armv7.json
termux-create-package build/termux-armv7.json
test -f ${APP_NAME}_${DEB_VERSION}_arm.deb || exit 1
mv ${APP_NAME}_*_arm.deb dist/${APP_NAME}_v${DEB_VERSION}_Termux_ARMv7.deb

sed -i 's/VAR-VERSION/'$DEB_VERSION'/' build/termux-armv8.json
termux-create-package build/termux-armv8.json
test -f ${APP_NAME}_${DEB_VERSION}_aarch64.deb || exit 1
mv ${APP_NAME}_*_aarch64.deb dist/${APP_NAME}_v${DEB_VERSION}_Termux_ARMv8.deb

(
cd dist;
rm -f checksums.txt
(
echo SHA256SUM:
sha256sum ${APP_NAME}_*.{tar.gz,zip,deb}
echo; echo MD5SUM:
md5sum ${APP_NAME}_*.{tar.gz,zip,deb}
) > checksums.txt
)

GH_TAGS=https://api.github.com/repos/$GITHUB_REPOSITORY/releases/tags
curl -s $GH_TAGS/$GIT_DESCRIBE > out.json
URL=$(jq -r '.upload_url' out.json | sed 's/{.*}//')
RELEASE_ID=$(jq -r '.id' out.json)

if [[ $URL != http* ]]; then
echo Cant get URL for $GIT_DESCRIBE
exit 1
fi

echo "Delete checksums.txt ..."

CHECKSUMS_URL=$(jq -r '.assets[] | select(.name == "checksums.txt") | .url' out.json)
if [[ $CHECKSUMS_URL != http* ]]; then
echo Cant get URL for checksums.txt
exit 1
fi

curl --silent -X DELETE -H "Authorization: token $GITHUB_TOKEN" $CHECKSUMS_URL

echo "Uploading asset ..."

for file in dist/checksums.txt dist/${APP_NAME}_*.deb; do
echo " Uploading $file"
GH_ASSET="$URL?name=$(basename $file)"
HTTP_CODE=$(curl --silent --output out.json -w '%{http_code}' \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Content-Type: application/octet-stream" \
--data-binary @"$file" \
$GH_ASSET
)
if [[ $HTTP_CODE != 2* ]]; then
jq --monochrome-output '' out.json
URL=https://api.github.com/repos/$GITHUB_REPOSITORY/releases/$RELEASE_ID
curl --silent -X DELETE -H "Authorization: token $GITHUB_TOKEN" $URL
exit 1
fi
done

0 comments on commit 22dade0

Please sign in to comment.