Skip to content
This repository has been archived by the owner on Jun 13, 2022. It is now read-only.

Commit

Permalink
HACK: strip unused bits
Browse files Browse the repository at this point in the history
ci: always release

Update .goreleaser.yml

Update release.yml

HACK: strip unnecessary bits

ci: format

chore: ignore dist

chore: update
  • Loading branch information
mochaaP committed May 2, 2022
1 parent 1c45fdb commit b06bc41
Show file tree
Hide file tree
Showing 46 changed files with 233 additions and 2,836 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: CI

on:
push:


jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Build with xgo
uses: crazy-max/ghaction-xgo@v1
with:
xgo_version: latest
go_version: 1.18
dest: dist
prefix: dnsd
targets: windows/386,windows/amd64,windows/arm64,linux/386,linux/amd64,linux/arm,linux/arm64,darwin/amd64,darwin/arm64
ldflags: -s -w
buildmode: default

- uses: actions/upload-artifact@v2
with:
path: dist/
44 changes: 0 additions & 44 deletions .github/workflows/docker-image.yml

This file was deleted.

30 changes: 22 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,45 @@
name: release
name: goreleaser

on:
push:
# Sequence of patterns matched against refs/tags
branches:
- "master"
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
- "v*"
pull_request:

permissions:
contents: write
packages: write
pull-requests: read

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
goreleaser:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17
go-version: 1.18

- name: Docker Login
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
if: startsWith(github.ref, 'refs/tags/')
with:
distribution: goreleaser
version: latest
args: release --rm-dist
env:
Expand Down
54 changes: 27 additions & 27 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
# Compiled Object files, Static and Dynamic libs (Shared Objects)
*.o
*.a
# Created by https://www.toptal.com/developers/gitignore/api/go
# Edit at https://www.toptal.com/developers/gitignore?templates=go

### Go ###
# If you prefer the allow list template instead of the deny list, see community template:
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
#
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
/ddns-go
__*
*.dylib
/dnsd

# Folders
_obj
_test
.vagrant
releases
tmp
/.idea/
vendor/
/dist
# Test binary, built with `go test -c`
*.test

# Architecture specific extensions/prefixes
trace.out
# Output of the go coverage tool, specifically when used with LiteIDE
*.out
.DS_Store
_testmain.go

*.exe
*.test
*.prof
profile.cov
coverage.html
/go.sum
# Go workspace file
go.work

### Go Patch ###
/vendor/
/Godeps/

# End of https://www.toptal.com/developers/gitignore/api/go

# Emacs backup files
*~
.*~
/.idea/
/.vscode/
/dist
58 changes: 21 additions & 37 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,48 +1,32 @@
# This is an example goreleaser.yaml file with some sane defaults.
# Make sure to check the documentation at http://goreleaser.com
before:
hooks:
# You may remove this if you don't use go modules.
- go mod download
# you may remove this if you don't need go generate
- go generate ./...
builds:
- env:
- CGO_ENABLED=0
- env: [CGO_ENABLED=0]
flags:
- -trimpath
goos:
- linux
- windows
- darwin
- freebsd
goarch:
- 386
- amd64
- arm
- arm64
- mips
- mipsle
- mips64
- mips64le
- "386"
- "amd64"
- "arm"
- "arm64"
- "mips"
gomips:
- hardfloat
- softfloat
ldflags:
- -s -w -X main.version={{.Tag}} -X main.buildTime={{.Date}}
archives:
- replacements:
darwin: Darwin
linux: Linux
windows: Windows
386: i386
amd64: x86_64
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ .Tag }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
mod_timestamp: '{{ .CommitTimestamp }}'
dockers:
- image_templates: ["ghcr.io/traidento/dnsd:{{ .Version }}"]
use: buildx
dockerfile: Dockerfile
build_flag_templates:
- --label=org.opencontainers.image.title={{ .ProjectName }}
- --label=org.opencontainers.image.description=Lightweight DDNS daemon
- --label=org.opencontainers.image.url=https://github.com/traidento/dnsd
- --label=org.opencontainers.image.source=https://github.com/traidento/dnsd
- --label=org.opencontainers.image.version={{ .Version }}
- --label=org.opencontainers.image.created={{ time "2022-05-02T16:09:08+08:00" }}
- --label=org.opencontainers.image.revision={{ .FullCommit }}
- --label=org.opencontainers.image.licenses=MIT
23 changes: 4 additions & 19 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,7 @@
# build stage
FROM golang:1.17 AS builder
FROM scratch

WORKDIR /app
COPY . .
RUN go env -w GO111MODULE=on \
&& go env -w GOPROXY=https://goproxy.cn,direct \
&& make clean build
ENV UPDATE_INTERVAL="300"

# final stage
FROM alpine
LABEL name=ddns-go
LABEL url=https://github.com/jeessy2/ddns-go
COPY dnsd /usr/bin/dnsd

WORKDIR /app
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories \
&& apk add --no-cache tzdata
ENV TZ=Asia/Shanghai
COPY --from=builder /app/ddns-go /app/ddns-go
EXPOSE 9876
ENTRYPOINT ["/app/ddns-go"]
CMD ["-l", ":9876", "-f", "300"]
ENTRYPOINT ["/usr/bin/dnsd"]
3 changes: 2 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
MIT License

Copyright (c) 2020 jeessy
Copyright (c) 2022 mochaaP

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -18,4 +19,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
SOFTWARE.
30 changes: 0 additions & 30 deletions Makefile

This file was deleted.

Loading

0 comments on commit b06bc41

Please sign in to comment.