Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a4579b399e | |||
| 7be52a79d6 | |||
| 5f2e956e80 | |||
| 242137d421 | |||
| 0c2b7ae461 | |||
| bb4d1439cf | |||
| d8b07d11a1 | |||
| 3e75a5b445 | |||
| 46177264a1 | |||
| ec9e6ca83c | |||
| e1953f339d |
63
.github/workflows/build.yml
vendored
Normal file
63
.github/workflows/build.yml
vendored
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
name: Build
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags: '*'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
prepare-data:
|
||||||
|
name: Prepare Data
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
tag: ${{ steps.prepare.outputs.SOURCE_TAG }}
|
||||||
|
repo: ${{ steps.prepare.outputs.REPO }}
|
||||||
|
lrepo: ${{ steps.prepare.outputs.LREPO }}
|
||||||
|
steps:
|
||||||
|
- id: prepare
|
||||||
|
name: Prepare environment variables
|
||||||
|
run: |
|
||||||
|
echo ::set-output name=SOURCE_NAME::${GITHUB_REF#refs/*/}
|
||||||
|
echo ::set-output name=SOURCE_BRANCH::${GITHUB_REF#refs/heads/}
|
||||||
|
echo ::set-output name=SOURCE_TAG::${GITHUB_REF#refs/tags/}
|
||||||
|
echo ::set-output name=REPO::${GITHUB_REPOSITORY#luketainton/}
|
||||||
|
echo ::set-output name=LREPO::${GITHUB_REPOSITORY#luketainton/} | tr '[:upper:]' '[:lower:]'
|
||||||
|
|
||||||
|
docker:
|
||||||
|
name: GitHub Package Registry
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: [prepare-data]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Login to GitHub Package Registry
|
||||||
|
run: echo ${{ secrets.PAT }} | docker login ghcr.io -u luketainton --password-stdin
|
||||||
|
- name: Build image for GitHub Package Registry
|
||||||
|
run: docker build . --file Dockerfile --tag ghcr.io/luketainton/${{ needs.prepare-data.outputs.lrepo }}:${{ needs.prepare-data.outputs.tag }} --tag ghcr.io/luketainton/${{ needs.prepare-data.outputs.lrepo }}:latest
|
||||||
|
- name: Push image to GitHub Package Registry
|
||||||
|
run: |
|
||||||
|
docker push ghcr.io/luketainton/${{ needs.prepare-data.outputs.lrepo }}:latest
|
||||||
|
docker push ghcr.io/luketainton/${{ needs.prepare-data.outputs.lrepo }}:${{ needs.prepare-data.outputs.tag }}
|
||||||
|
|
||||||
|
build:
|
||||||
|
name: Build and Release
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: [prepare-data]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Build artifacts
|
||||||
|
run: |
|
||||||
|
docker run --rm -w /go/src/app -v ${PWD}:/go/src/app -e CGO_ENABLED=0 -e GOARCH=amd64 -e GOOS=darwin golang:alpine go build -o /go/src/app/${{ needs.prepare-data.outputs.repo }}-${{ needs.prepare-data.outputs.tag }}-darwin-amd64
|
||||||
|
docker run --rm -w /go/src/app -v ${PWD}:/go/src/app -e CGO_ENABLED=0 -e GOARCH=arm64 -e GOOS=darwin golang:alpine go build -o /go/src/app/${{ needs.prepare-data.outputs.repo }}-${{ needs.prepare-data.outputs.tag }}-darwin-arm64
|
||||||
|
docker run --rm -w /go/src/app -v ${PWD}:/go/src/app -e CGO_ENABLED=0 -e GOARCH=amd64 -e GOOS=linux golang:alpine go build -o /go/src/app/${{ needs.prepare-data.outputs.repo }}-${{ needs.prepare-data.outputs.tag }}-linux-amd64
|
||||||
|
docker run --rm -w /go/src/app -v ${PWD}:/go/src/app -e CGO_ENABLED=0 -e GOARCH=amd64 -e GOOS=windows golang:alpine go build -o /go/src/app/${{ needs.prepare-data.outputs.repo }}-${{ needs.prepare-data.outputs.tag }}-win-amd64.exe
|
||||||
|
docker run --rm -w /go/src/app -v ${PWD}:/go/src/app -e CGO_ENABLED=0 -e GOARCH=386 -e GOOS=windows golang:alpine go build -o /go/src/app/${{ needs.prepare-data.outputs.repo }}-${{ needs.prepare-data.outputs.tag }}-win-x86.exe
|
||||||
|
- uses: meeDamian/github-release@v2.0.3
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
tag: ${{ needs.prepare-data.outputs.tag }}
|
||||||
|
gzip: false
|
||||||
|
files: >
|
||||||
|
${{ needs.prepare-data.outputs.repo }}-${{ needs.prepare-data.outputs.tag }}-darwin-amd64
|
||||||
|
${{ needs.prepare-data.outputs.repo }}-${{ needs.prepare-data.outputs.tag }}-darwin-arm64
|
||||||
|
${{ needs.prepare-data.outputs.repo }}-${{ needs.prepare-data.outputs.tag }}-linux-amd64
|
||||||
|
${{ needs.prepare-data.outputs.repo }}-${{ needs.prepare-data.outputs.tag }}-win-amd64.exe
|
||||||
|
${{ needs.prepare-data.outputs.repo }}-${{ needs.prepare-data.outputs.tag }}-win-x86.exe
|
||||||
|
|
||||||
9
Dockerfile
Normal file
9
Dockerfile
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
FROM golang:1.16-alpine as build
|
||||||
|
WORKDIR /go/src/app
|
||||||
|
COPY . /go/src/app
|
||||||
|
RUN CGO_ENABLED=0 go build -o /go/bin/app
|
||||||
|
|
||||||
|
FROM gcr.io/distroless/base-debian10
|
||||||
|
LABEL maintainer="Luke Tainton <luke@tainton.uk>"
|
||||||
|
COPY --from=build /go/bin/app /
|
||||||
|
CMD ["/app"]
|
||||||
@@ -2,7 +2,6 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -26,8 +25,6 @@ type IPAddressInfo struct {
|
|||||||
|
|
||||||
func printIPInfo(input string, wantPrefixes bool) {
|
func printIPInfo(input string, wantPrefixes bool) {
|
||||||
var IPInfo IPAddressInfo = getIPInfo(input)
|
var IPInfo IPAddressInfo = getIPInfo(input)
|
||||||
fmt.Printf("%+v\n", IPInfo)
|
|
||||||
os.Exit(200)
|
|
||||||
var location string = IPInfo.Country + "/" + IPInfo.RegionName + "/" + IPInfo.City
|
var location string = IPInfo.Country + "/" + IPInfo.RegionName + "/" + IPInfo.City
|
||||||
var bgpAS string = strings.Fields(IPInfo.AS)[0]
|
var bgpAS string = strings.Fields(IPInfo.AS)[0]
|
||||||
fmt.Println("IP Address: ", IPInfo.IPAddress)
|
fmt.Println("IP Address: ", IPInfo.IPAddress)
|
||||||
|
|||||||
1
Main.go
1
Main.go
@@ -17,6 +17,7 @@ func main() {
|
|||||||
|
|
||||||
flag.Usage = func() {
|
flag.Usage = func() {
|
||||||
fmt.Printf("Usage of iPilot: \n")
|
fmt.Printf("Usage of iPilot: \n")
|
||||||
|
fmt.Printf("Example: iPilot -b=false -i=me -p \n")
|
||||||
fmt.Printf(" -b bool enable/disable header (default true)\n")
|
fmt.Printf(" -b bool enable/disable header (default true)\n")
|
||||||
fmt.Printf(" -h bool view help\n")
|
fmt.Printf(" -h bool view help\n")
|
||||||
fmt.Printf(" -i string IP address or domain\n")
|
fmt.Printf(" -i string IP address or domain\n")
|
||||||
|
|||||||
Reference in New Issue
Block a user