Skip to content
Open
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
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/release
36 changes: 36 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Release

on:
push:
tags: ['v*']

jobs:
test:
uses: ./.github/workflows/test.yaml
secrets: inherit
release:
needs: [test]
runs-on: ubuntu-latest
name: Compile & archive release binaries
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Cache xgo-cache
uses: actions/cache@v4
with:
path: /home/runner/.xgo-cache
key: xgo-cache
- name: Install techknowlogick/xgo
run: go install src.techknowlogick.com/[email protected]+1.23.2
- uses: docker/setup-buildx-action@v3
- name: Build rambler
run: PATH=/home/runner/.go/bin:$PATH make release
- name: Archive releases
uses: actions/upload-artifact@v4
with:
name: release
path: release/github.com/elwinar
retention-days: 90
if-no-files-found: error
18 changes: 18 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Test

on:
push:
branches: ['*']
tags: ['!v*']
workflow_call: {}

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Test
run: go test ./...
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@

*.iml
.idea/
/release
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
targets="windows/amd64,windows/386,darwin/arm64,darwin/amd64,darwin/386,linux/amd64,linux/386"
targets="windows/amd64,windows/386,darwin/arm64,darwin/amd64,darwin/386,linux/amd64,linux/arm64,linux/386"
pkg="github.com/elwinar/rambler"
version=$(shell git describe --tags)
ldflags="-X main.VERSION=${version}"
Expand All @@ -16,8 +16,11 @@ help: ## Get help

.PHONY: release
release: ## Build the release files
xgo --dest release --targets=$(targets) --ldflags=$(ldflags) $(pkg)
docker-compose run -w /src main sh -c 'apk add build-base && go build -o release/rambler-alpine-amd64 --ldflags=${ldflags}'
mkdir -p release/github.com/elwinar
xgo --dest release --targets=$(targets) --ldflags=$(ldflags) .
docker buildx build --output type=tar --build-arg VERSION=${version} --platform linux/amd64 --file build.Dockerfile . | tar -xO rambler >release/github.com/elwinar/rambler-alpine-amd64
docker buildx build --output type=tar --build-arg VERSION=${version} --platform linux/arm64 --file build.Dockerfile . | tar -xO rambler >release/github.com/elwinar/rambler-alpine-arm64
chmod +x release/github.com/elwinar/rambler-alpine-amd64 release/github.com/elwinar/rambler-alpine-arm64

.PHONY: test
test: ## Test the project
Expand Down
10 changes: 10 additions & 0 deletions build.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM golang:1.21
ARG TARGETARCH
ARG VERSION
COPY . /go/src/github.com/elwinar/rambler
WORKDIR /go/src/github.com/elwinar/rambler
RUN go get ./...
RUN go build -ldflags="-X main.VERSION=${VERSION} -s -linkmode external -extldflags -static -w"

FROM scratch
COPY --from=0 /go/src/github.com/elwinar/rambler/rambler /
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/elwinar/rambler

go 1.18
go 1.21

require (
dario.cat/mergo v1.0.1
Expand Down