From 1481ba9c86626534f6961d7e3e3abf45526ceaf1 Mon Sep 17 00:00:00 2001 From: Anagani Sai Kiran <9448273+anaganisk@users.noreply.github.com> Date: Fri, 22 Oct 2021 23:33:59 +0530 Subject: [PATCH] create github actions --- .circleci/config.yml | 46 ---------------------------------- .github/workflows/go.yml | 53 ++++++++++++++++++++++++++++++++++++++++ README.md | 2 +- ci-build-script.sh | 35 -------------------------- 4 files changed, 54 insertions(+), 82 deletions(-) delete mode 100644 .circleci/config.yml create mode 100644 .github/workflows/go.yml delete mode 100755 ci-build-script.sh diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 5c9cdc5..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,46 +0,0 @@ -version: 2 -jobs: - build: - docker: - - image: circleci/golang:1.11 - working_directory: ~/app - steps: - - checkout - - run: - name: Build - command: | - ./ci-build-script.sh . - cp ./digitalocean-dynamic-ip.sample.json ./releases/ - - persist_to_workspace: - root: . - paths: - - ./releases - - publish-github-release: - docker: - - image: cibuilds/github:0.10 - working_directory: ~/app - steps: - - attach_workspace: - at: ~/app - - run: - name: "Publish Release on GitHub" - command: | - 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+$/ diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml new file mode 100644 index 0000000..4f38819 --- /dev/null +++ b/.github/workflows/go.yml @@ -0,0 +1,53 @@ +name: Go + +on: + push: + tags: + - '*' +jobs: + + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.11 + + - name: Build + run: | + #see https://en.wikipedia.org/wiki/Raspberry_Pi#Specifications for RPi arm versions + #see https://github.com/golang/go/wiki/GoArm + platforms=("windows/amd64" "windows/386" "darwin/amd64" "linux/386" "linux/amd64" "linux/arm/6" "linux/arm/7" "linux/arm64/8" "freebsd/386" "freebsd/amd64") + mkdir -p releases + for platform in "${platforms[@]}" + do + platform_split=(${platform//\// }) + GOOS=${platform_split[0]} + GOARCH=${platform_split[1]} + GOARM=${platform_split[2]} + output_name='digitalocean-dynamic-dns-ip-'$GOOS'-'$GOARCH + if [[ ! -z "$GOARM" ]]; then + output_name+="v${GOARM}" + # arm v8 is only supported for ARCH=arm64 and requires an empty GOARM version + if [[ "8" -eq "$GOARM" ]]; then + GOARM="" + fi + fi + if [ $GOOS = "windows" ]; then + output_name+='.exe' + fi + env GOOS="$GOOS" GOARCH="$GOARCH" GOARM="$GOARM" go build -o "releases/$output_name" + if [ $? -ne 0 ]; then + echo 'An error has occurred! Aborting the script execution...' + exit 1 + fi + done + - uses: ncipollo/release-action@v1 + name: "Create Release" + with: + artifacts: "releases/*" + token: ${{ secrets.GITHUB_TOKEN }} + diff --git a/README.md b/README.md index 847f463..a875e75 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# DIGITAL OCEAN DYNAMIC IP API CLIENT [![CircleCI](https://circleci.com/gh/anaganisk/digitalocean-dynamic-dns-ip/tree/master.svg?style=svg)](https://circleci.com/gh/anaganisk/digitalocean-dynamic-dns-ip/tree/master) +# 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. diff --git a/ci-build-script.sh b/ci-build-script.sh deleted file mode 100755 index 224b183..0000000 --- a/ci-build-script.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash -package=$1 -if [[ -z "$package" ]]; then - echo "usage: $0 " - exit 1 -fi -package_split=(${package//\// }) -package_name=${package_split[-1]} -#see https://en.wikipedia.org/wiki/Raspberry_Pi#Specifications for RPi arm versions -#see https://github.com/golang/go/wiki/GoArm -platforms=("windows/amd64" "windows/386" "darwin/amd64" "linux/386" "linux/amd64" "linux/arm/6" "linux/arm/7" "linux/arm64/8" "freebsd/386" "freebsd/amd64") -mkdir -p releases -for platform in "${platforms[@]}" -do - platform_split=(${platform//\// }) - GOOS=${platform_split[0]} - GOARCH=${platform_split[1]} - GOARM=${platform_split[2]} - output_name='digitalocean-dynamic-dns-ip-'$GOOS'-'$GOARCH - if [[ ! -z "$GOARM" ]]; then - output_name+="v${GOARM}" - # arm v8 is only supported for ARCH=arm64 and requires an empty GOARM version - if [[ "8" -eq "$GOARM" ]]; then - GOARM="" - fi - fi - if [ $GOOS = "windows" ]; then - output_name+='.exe' - fi - env GOOS="$GOOS" GOARCH="$GOARCH" GOARM="$GOARM" go build -o "releases/$output_name" "$package_name" - if [ $? -ne 0 ]; then - echo 'An error has occurred! Aborting the script execution...' - exit 1 - fi -done \ No newline at end of file