diff options
| author | Darien Raymond <[email protected]> | 2018-12-11 11:56:38 +0100 |
|---|---|---|
| committer | Darien Raymond <[email protected]> | 2018-12-11 11:56:38 +0100 |
| commit | 790e7a392d0199f9422e44219da34dcebb3ed99b (patch) | |
| tree | d5e2d95bba9126582afc2cf00f03cf9779889be8 | |
| parent | 0da27c55ef0ddccf0250f63922730f28e6ded75b (diff) | |
migrate to azure pipelines
| -rw-r--r-- | azure-pipelines.yml | 24 | ||||
| -rw-r--r-- | generate.sh | 34 | ||||
| -rw-r--r-- | release.sh | 17 |
3 files changed, 24 insertions, 51 deletions
diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 00000000..15ef7ecc --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,24 @@ +jobs: +- job: build.geoip + timeoutInMinutes: 30 + + pool: + vmImage: 'ubuntu-16.04' + + variables: + GOPATH: '$(system.defaultWorkingDirectory)' + + steps: + - checkout: self + - task: GoTool@0 + inputs: + version: '1.11.2' + - script: | + go version + $(Build.SourcesDirectory)/generate.sh + workingDirectory: '$(system.defaultWorkingDirectory)/publish' + displayName: 'Generate' + - task: PublishPipelineArtifact@0 + inputs: + artifactName: 'geosite' + targetPath: '$(system.defaultWorkingDirectory)/publish' diff --git a/generate.sh b/generate.sh index 3efb2829..cd8c8ac8 100644 --- a/generate.sh +++ b/generate.sh @@ -2,27 +2,6 @@ set -e -apt -y install curl unzip git jq - -mkdir /v2 -cd /v2 - -echo "Installing Go runtime" -GO_INSTALL=golang.tar.gz -curl -L -o ${GO_INSTALL} https://storage.googleapis.com/golang/go1.11.2.linux-amd64.tar.gz -tar -C /usr/local -xzf ${GO_INSTALL} -export GOPATH=/v2/go -export PATH=$PATH:${GOPATH}/bin:/usr/local/go/bin - -function getattr() { - curl -s -H "Metadata-Flavor: Google" http://metadata.google.internal/computeMetadata/v1/$2/attributes/$1 -} - -GITHUB_TOKEN=$(getattr "github_token" "project") - -RELEASE_TAG=$(date +%Y%m%d) -echo "Releasing GeoIP at ${RELEASE_TAG}" - curl -L -O http://geolite.maxmind.com/download/geoip/database/GeoLite2-Country-CSV.zip unzip GeoLite2-Country-CSV.zip rm GeoLite2-Country-CSV.zip @@ -30,16 +9,3 @@ mv GeoLite2* geoip CGO_ENABLED=0 go get -u v2ray.com/ext/tools/geoip/main main --country=./geoip/GeoLite2-Country-Locations-en.csv --ipv4=./geoip/GeoLite2-Country-Blocks-IPv4.csv --ipv6=./geoip/GeoLite2-Country-Blocks-IPv6.csv - -JSON_DATA=$(echo "{}" | jq -c ".tag_name=\"${RELEASE_TAG}\"") -RELEASE_ID=$(curl --data "${JSON_DATA}" -H "Authorization: token ${GITHUB_TOKEN}" -X POST https://api.github.com/repos/v2ray/geoip/releases | jq ".id") - -function uploadfile() { - FILE=$1 - CTYPE=$(file -b --mime-type $FILE) - curl -H "Authorization: token ${GITHUB_TOKEN}" -H "Content-Type: ${CTYPE}" --data-binary @$FILE "https://uploads.github.com/repos/v2ray/geoip/releases/${RELEASE_ID}/assets?name=$(basename $FILE)" -} - -uploadfile ./geoip.dat - -shutdown -h now diff --git a/release.sh b/release.sh deleted file mode 100644 index c501a91a..00000000 --- a/release.sh +++ /dev/null @@ -1,17 +0,0 @@ -PROJECT=$1 - -echo "Launching build machine." -DIR="$(dirname "$0")" -RAND="$(openssl rand -hex 5)" -ZONES=("us-central1-b" "us-central1-c" "europe-west1-d" "us-east1-d") - -for zone in "${ZONES[@]}"; do -gcloud compute instances create "v2raygeoip-${RAND}" \ - --machine-type=n1-standard-1 \ - --metadata-from-file=startup-script=${DIR}/generate.sh \ - --zone=${zone} \ - --project ${PROJECT} -if [ $? -eq 0 ]; then - exit 0 -fi -done |
