added circle ci

This commit is contained in:
Sai Kiran Anagani 2019-10-29 17:07:49 +05:30
parent 9eed6ba6d8
commit 47b51d0cf0
6 changed files with 82 additions and 4 deletions

34
.circleci/config.yml Normal file
View File

@ -0,0 +1,34 @@
version: 2
jobs:
build:
docker:
- image: circleci/golang:1.8
working_directory: /go/src/github.com/anaganisk/digitalocean-dynamic-dns-ip
steps:
- checkout
- attach_workspace:
at: ./releases
- run:
name: Build
command: |
echo 'export GO111MODULE=on' >> $BASH_ENV
source $BASH_ENV
./ci-build-script.sh
ghr -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} -delete ${CIRCLE_TAG} ./releases/
workflows:
version: 2
main:
jobs:
- build:
filters:
tags:
only: /^\d+\.\d+\.\d+$/
- publish-github-release:
requires:
- build
filters:
branches:
ignore: /.*/
tags:
only: /^\d+\.\d+\.\d+$/

3
.gitignore vendored
View File

@ -4,4 +4,5 @@ digitalocean-dynamic-dns-ip
digitalocean-dynamic-ip.json digitalocean-dynamic-ip.json
# GoLand IDE # GoLand IDE
.idea/ .idea/
releases

View File

@ -1,10 +1,12 @@
# DIGITAL OCEAN DYNAMIC IP API CLIENT # DIGITAL OCEAN DYNAMIC IP API CLIENT
A simple script in Go language to automatically update Digital ocean DNS records if you have a dynamic IP. Since it can be compiled on any platform, you can use it along with raspberrypi etc. A simple script in Go language to automatically update Digital ocean DNS records if you have a dynamic IP. Since it can be compiled on any platform, you can use it along with raspberrypi etc.
To find your Dynamic IP, this program will call out to https://ipv4bot.whatismyipaddress.com for ipv4 addresses and https://ipv6bot.whatismyipaddress.com for ipv6 addresses. This is to support dual-stack environments. (These URLs can be customized; see Usage, below.) To find your Dynamic IP, this program will call out to https://ipv4bot.whatismyipaddress.com for ipv4 addresses and https://ipv6bot.whatismyipaddress.com for ipv6 addresses. This is to support dual-stack environments. (These URLs can be customized; see Usage, below.)
## Requirements ## Requirements
Requires Git, Go 1.8+, and https://github.com/mitchellh/go-homedir for building.
Requires Git, Go 1.8+.
Requires that the record already exists in DigitalOcean's DNS so that it can be updated. Requires that the record already exists in DigitalOcean's DNS so that it can be updated.
(manually find your IP and add it to DO's DNS it will later be updated) (manually find your IP and add it to DO's DNS it will later be updated)
@ -12,11 +14,18 @@ Requires that the record already exists in DigitalOcean's DNS so that it can be
Requires a Digital Ocean API key that can be created at https://cloud.digitalocean.com/account/api/tokens. Requires a Digital Ocean API key that can be created at https://cloud.digitalocean.com/account/api/tokens.
## Building ## Building
You first need to install the "homedir" module if you aren't using it in another project. To install the module, run `go get github.com/mitchellh/go-homedir`
Once the module is fetched, you should be able to compile the program using `go build` You first need to install the "homedir" module if you aren't using it in another project. To install the module.
```bash
# Skip to next step, if you have GO111MODULE=on in your environment it is fetched automatically
go get github.com/mitchellh/go-homedir
# build the project
go build
```
## Usage ## Usage
```bash ```bash
# clone the repo in ~/go/src/github.com/anaganisk: # clone the repo in ~/go/src/github.com/anaganisk:
git clone https://github.com/anaganisk/digitalocean-dynamic-dns-ip.git git clone https://github.com/anaganisk/digitalocean-dynamic-dns-ip.git

27
ci-build-script.sh Executable file
View File

@ -0,0 +1,27 @@
#!/bin/bash
package=$1
if [[ -z "$package" ]]; then
echo "usage: $0 <package-name>"
exit 1
fi
package_split=(${package//\// })
package_name=${package_split[-1]}
platforms=("windows/amd64" "windows/386" "darwin/amd64" "linux/386" "linux/amd64" "linux/arm" "linux/arm64")
mkdir releases
for platform in "${platforms[@]}"
do
platform_split=(${platform//\// })
GOOS=${platform_split[0]}
GOARCH=${platform_split[1]}
output_name=$package_name'-'$GOOS'-'$GOARCH
if [ $GOOS = "windows" ]; then
output_name+='.exe'
fi
env GOOS=$GOOS GOARCH=$GOARCH go build -o releases/$output_name $package
if [ $? -ne 0 ]; then
echo 'An error has occurred! Aborting the script execution...'
exit 1
fi
done

5
go.mod Normal file
View File

@ -0,0 +1,5 @@
module github.com/anaganisk/digitalocean-dynamic-dns-ip
require github.com/mitchellh/go-homedir v1.1.0
go 1.13

2
go.sum Normal file
View File

@ -0,0 +1,2 @@
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=