diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..32afaba --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,27 @@ +name: Go Test + +on: + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: stable + + - name: Run tests + run: go test -v \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..30629d5 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,41 @@ +# .github/workflows/release.yml +name: goreleaser + +on: + pull_request: + push: + # run only against tags + tags: + - "*" + +permissions: + contents: write + # packages: write + # issues: write + +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: stable + # More assembly might be required: Docker logins, GPG, etc. + # It all depends on your needs. + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v5 + with: + # either 'goreleaser' (default) or 'goreleaser-pro' + distribution: goreleaser + # 'latest', 'nightly', or a semver + version: latest + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # Your GoReleaser Pro key, if you are using the 'goreleaser-pro' distribution + # GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }} \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 53f1486..0000000 --- a/.travis.yml +++ /dev/null @@ -1,20 +0,0 @@ ---- -os: linux -dist: xenial # Python3.7 virtualenv is available only on Travis Xenial VMs. -language: go -sudo: true -go: - - "1.13" -env: - - GO111MODULE=on -before_install: - - sudo apt-get update -q - - sudo apt-get install -y python3 python3-dev python3-pip python3-setuptools - - sudo pip3 install -r scripts/requirements.txt -install: - - true # just skip -script: - - go test -v -after_success: - - test -n "$TRAVIS_TAG" && curl -sL https://git.io/goreleaser | bash - - test -n "$TRAVIS_TAG" && python3 -u scripts/upload2qiniu.py \ No newline at end of file diff --git a/go.mod b/go.mod index 086916b..10344b9 100644 --- a/go.mod +++ b/go.mod @@ -26,6 +26,7 @@ require ( github.com/kardianos/osext v0.0.0-20170510131534-ae77be60afb1 // indirect github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 github.com/kr/binarydist v0.1.0 // indirect + github.com/kr/pretty v0.1.0 // indirect github.com/kr/pty v1.1.8 github.com/levigross/grequests v0.0.0-20190130132859-37c80f76a0da github.com/mholt/archiver v2.0.1-0.20171012052341-26cf5bb32d07+incompatible @@ -39,9 +40,9 @@ require ( github.com/prometheus/procfs v0.0.2 github.com/rs/cors v1.6.0 github.com/sevlyar/go-daemon v0.1.4 - github.com/shogo82148/androidbinary v1.0.1 - github.com/shurcooL/httpfs v0.0.0-20190707220628-8d4bc4ba7749 // indirect - github.com/shurcooL/vfsgen v0.0.0-20200824052919-0d455de96546 // indirect + github.com/shogo82148/androidbinary v1.0.5 + github.com/shurcooL/httpfs v0.0.0-20230704072500-f1e31cf0ba5c // indirect + github.com/shurcooL/vfsgen v0.0.0-20230704071429-0000e147ea92 // indirect github.com/sirupsen/logrus v1.6.0 github.com/stretchr/testify v1.4.0 github.com/ulikunitz/xz v0.5.5 // indirect diff --git a/scripts/requirements.txt b/scripts/requirements.txt deleted file mode 100644 index 6e93b03..0000000 --- a/scripts/requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -qiniu~=7.2 -retry~=0.9.2 diff --git a/scripts/upload2qiniu.py b/scripts/upload2qiniu.py deleted file mode 100644 index be55604..0000000 --- a/scripts/upload2qiniu.py +++ /dev/null @@ -1,79 +0,0 @@ -# coding: utf-8 - -import argparse -import glob -import re -import logging -import os - -import qiniu.config -from qiniu import Auth, etag, put_file -from qiniu import Zone, set_default -from retry import retry - -class Qiniu: - def __init__(self, access_key, secret_key, bucket_name: str): - self._access_key = access_key - self._secret_key = secret_key - self._auth = Auth(access_key, secret_key) - self._bucket = bucket_name - - @retry(tries=5, delay=0.5, jitter=0.1, logger=logging) - def upload_file(self, key, localfile): - token = self._auth.upload_token(self._bucket, key) - ret, info = put_file(token, key, localfile) - if ret: # ret possibly is None - assert ret['key'] == key - assert ret['hash'] == etag(localfile) - return info - - -# Get key from https://portal.qiniu.com/user/key -access_key = 'caBese-UQYXwQeigGqtdgwybP2Qh2AlDPdcEd42C' # here only-for-test -secret_key = '........' - -zone = Zone(up_host='https://up.qiniup.com', - up_host_backup='https://upload.qiniup.com', - io_host='http://iovip.qbox.me', - scheme='https') -set_default(default_zone=zone) - - -def main(): - parser = argparse.ArgumentParser() - parser.add_argument("-A", - '--access-key', - help='access key, env-var QINIU_ACCESS_KEY', - default=os.environ.get("QINIU_ACCESS_KEY", access_key)) - parser.add_argument("-S", - "--secret-key", - help='secret key, env-var QINIU_SECRET_KEY', - default=os.environ.get("QINIU_SECRET_KEY", secret_key)) - parser.add_argument("-B", - "--bucket", - help='bucket name', - default=os.environ.get("QINIU_BUCKET", "atxupload")) - args = parser.parse_args() - - assert args.access_key - assert args.secret_key - assert args.bucket - - qn = Qiniu(args.access_key, args.secret_key, args.bucket) - checksum_path = glob.glob("*/atx-agent_*_checksums.txt")[0] - distdir = os.path.dirname(checksum_path) - - version = re.search(r"([\d.]+)", checksum_path).group(0) - print(checksum_path, version) - key_prefix = "openatx/atx-agent/releases/download/" + version + "/" - qn.upload_file(key_prefix + os.path.basename(checksum_path), checksum_path) - with open(checksum_path, 'r', encoding='utf-8') as f: - for line in f: - _, filename = line.split() - key = key_prefix + filename - print("-", filename, "->", key) - qn.upload_file(key, os.path.join(distdir, filename)) - - -if __name__ == "__main__": - main() diff --git a/update_test.go b/update_test.go index 22177f1..6adcd21 100644 --- a/update_test.go +++ b/update_test.go @@ -14,12 +14,12 @@ func TestFormatString(t *testing.T) { assert.Equal(t, s, "a x y x") } -func TestGetLatestVersion(t *testing.T) { - version, err := getLatestVersion() - assert.NoError(t, err) - t.Logf("version: %s", version) - assert.NotEqual(t, version, "") -} +//func TestGetLatestVersion(t *testing.T) { + //version, err := getLatestVersion() + //assert.NoError(t, err) + //t.Logf("version: %s", version) + //assert.NotEqual(t, version, "") +//} func TestGetChecksums(t *testing.T) { maps, err := getChecksums("0.0.1")