Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add project CI and Go skeleton #1

Merged
merged 4 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file

version: 2
updates:
- package-ecosystem: "gomod" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
88 changes: 88 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
---
name: release

on:
push:
tags:
- 'v*'

env:
IMAGE_NAME: anycastd

jobs:
hadolint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: hadolint/hadolint-action@v3.1.0
with:
dockerfile: Dockerfile

markdownlint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: articulate/actions-markdownlint@v1

unittests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.22.x'
- name: Install dependencies
run: go mod download
- name: Test with the Go CLI
run: go test ./...
- name: Build
run: go build -v ./...

build:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
needs:
- hadolint
- markdownlint
- unittests
steps:
- name: Define build timestamp
id: timestamp
run: echo "::set-output name=now::$(date -u +'%Y%m%d%H%M%S')"
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.22.x'
- name: Install dependencies
run: go mod download
- name: Build & Publish release release
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
platforms: amd64
push: true
tags: |
ghcr.io/${{ github.repository }}/${{ env.IMAGE_NAME }}:v${{ github.ref_name }}
ghcr.io/${{ github.repository }}/${{ env.IMAGE_NAME }}:v${{ github.ref_name }}-${{ steps.timestamp.outputs.now }}
outputs: type=image,name=ghcr.io/${{ github.repository }}/${{ env.IMAGE_NAME }},annotation-index.org.opencontainers.image.description=${{ env.IMAGE_NAME }}
59 changes: 59 additions & 0 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
name: verify

on:
push:
branches:
- master
pull_request:
types:
- opened
- reopened
- edited
- synchronize

jobs:
hadolint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: hadolint/hadolint-action@v3.1.0
with:
dockerfile: Dockerfile

markdownlint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: articulate/actions-markdownlint@v1

unittests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.22.x'
- name: Install dependencies
run: go mod download
- name: Test with the Go CLI
run: go test ./...

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '1.22.x'
- name: Install dependencies
run: go mod download
- name: Build project against .goreleaser.yaml
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
args: build --snapshot
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24 changes: 24 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
builds:
- id: anycastd
main: ./cmd/anycastd
binary: anycastd
ldflags:
- -s -w -X main.appVersion={{.Version}} -X main.buildTimestamp={{.Date}}
env:
- CGO_ENABLED=0
goos:
- linux
goarch:
- amd64
- arm64
goamd64: ["v1", "v2", "v3"]
goarm: ["7"]
mod_timestamp: "{{ .CommitTimestamp }}"
archives:
- format: binary
checksum:
name_template: "checksums.txt"
algorithm: sha256
split: false
disable: false
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM scratch

COPY --chmod=0755 --chown=root:root dist/anycastd_linux_amd64_v3/anycastd /anycastd

ENTRYPOINT [ "/anycastd" ]
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# anycastd

Simple daemon to make BGP announces if service is alive
5 changes: 5 additions & 0 deletions cmd/anycastd/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package anycastd

func main() {
panic("not implemented")
}
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/teran/anycastd

go 1.22.3
Loading