Skip to content

Commit

Permalink
add goreleaser workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
fredcarle committed Nov 11, 2023
1 parent ec46f7d commit ff72790
Show file tree
Hide file tree
Showing 5 changed files with 191 additions and 134 deletions.
51 changes: 0 additions & 51 deletions .github/workflows/pull-docker-image.yml

This file was deleted.

83 changes: 0 additions & 83 deletions .github/workflows/push-docker-image-to-registries.yml

This file was deleted.

62 changes: 62 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Copyright 2023 Democratized Data Foundation
#
# Use of this software is governed by the Business Source License
# included in the file licenses/BSL.txt.
#
# As of the Change Date specified in that file, in accordance with
# the Business Source License, use of this software will be governed
# by the Apache License, Version 2.0, included in the file
# licenses/APL.txt.

# This workflow builds the AMI using packer, if the build is successfull
# then it will deploy the AMI using terraform apply, onto AWS.
name: Release workflow

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

permissions:
contents: write
packages: write
issues: write

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout code into the directory
uses: actions/checkout@v3

- name: Setup Go environment explicitly
uses: actions/setup-go@v3
with:
go-version: "1.20"
check-latest: true

- name: Build modules
run: make deps:modules

- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser-pro
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_REPOSITORY: ${{ github.repository }}
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
112 changes: 112 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
version: 1

dist: ./build

before:
hooks:
- go mod tidy
- make deps:playground

after:
hooks:
- cmd: docker pull {{ .Env.GITHUB_REPOSITORY }}:latest
- cmd: docker run --rm {{ .Env.GITHUB_REPOSITORY }}:latest

builds:
- id: "defradb"
main: ./cmd/defradb
env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
goarch:
- amd64
- arm64

- id: "defradb+pg"
main: ./cmd/defradb
env:
- CGO_ENABLED=0
flags:
- -tags=playground
goos:
- linux
- windows
- darwin
goarch:
- amd64
- arm64


archives:
- id: defradb+pg
builds:
- defradb+pg
format: binary
# this name template makes the OS and Arch compatible with the results of `uname`.
name_template: '{{ .Binary }}+pg_{{ .Version }}_{{ .Os }}_{{- if eq .Arch "amd64" }}x86_64{{- else }}{{ .Arch }}{{ end }}{{- if .Arm }}v{{ .Arm }}{{ end }}'
- id: defradb
builds:
- defradb
format: binary
# this name template makes the OS and Arch compatible with the results of `uname`.
name_template: '{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{- if eq .Arch "amd64" }}x86_64{{- else }}{{ .Arch }}{{ end }}{{- if .Arm }}v{{ .Arm }}{{ end }}'


release:
header: |
DefraDB v0.8 is a major pre-production release. Until the stable version 1.0 is reached, the SemVer minor patch number will denote notable releases, which will give the project freedom to experiment and explore potentially breaking changes.
To get a full outline of the changes, we invite you to review the official changelog below. This release does include a Breaking Change to existing v0.7.x databases. If you need help migrating an existing deployment, reach out at [email protected] or join our Discord at https://discord.source.network/.
name_template: "v{{.Version}} Release"

changelog:
sort: asc
groups:
- title: Features
regexp: '^feat:.*'
order: 0
- title: Fix
regexp: '^fix:.*'
order: 1
- title: Tooling
regexp: '^tools:.*'
order: 2
- title: Documentation
regexp: '^docs:.*'
order: 3
- title: Refactoring
regexp: '^refactor:.*'
order: 4
- title: Testing
regexp: '^test:.*'
order: 5

source:
enabled: true

milestones:
- close: true
fail_on_error: true
name_template: "DefraDB v0.8"

dockers:
- ids:
- "defradb+pg"
image_templates:
- "{{ .Env.GITHUB_REPOSITORY }}:latest"
- "{{ .Env.GITHUB_REPOSITORY }}:{{ .Version }}"
- "ghcr.io/{{ .Env.GITHUB_REPOSITORY }}:{{ .Version }}"
build_flag_templates:
- "--pull"
- "--label=org.opencontainers.image.description=DefraDB is a Peer-to-Peer Edge Database."
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.name={{.ProjectName}}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.version={{.Version}}"
- "--label=org.opencontainers.image.source={{.GitURL}}"
- "--platform=linux/amd64"
dockerfile: ./tools/goreleaser.containerfile

17 changes: 17 additions & 0 deletions tools/goreleaser.containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# syntax=docker/dockerfile:1

# An image to run defradb.

# Stage: RUN
FROM debian:bookworm-slim
COPY defradb /defradb

# Documents which ports are normally used.
# To publish the ports: `docker run -p 9181:9181` ...
EXPOSE 9161
EXPOSE 9171
EXPOSE 9181

# Default command provided for convenience.
# e.g. docker run -p 9181:9181 source/defradb start --url 0.0.0.0:9181
ENTRYPOINT [ "/defradb" ]

0 comments on commit ff72790

Please sign in to comment.