Skip to content

Commit

Permalink
all: Prepare for release.
Browse files Browse the repository at this point in the history
  • Loading branch information
dennwc committed Jul 24, 2023
1 parent 1882364 commit c318932
Show file tree
Hide file tree
Showing 6 changed files with 123 additions and 31 deletions.
113 changes: 113 additions & 0 deletions .github/workflows/build-and-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
name: Test and release

on:
push:
branches:
- master
- ci_tests
tags:
- '*'
pull_request:
branches:
- master

env:
DOCKER_IMAGE_NAME: ghcr.io/cayleygraph/cayley

jobs:

tests:
name: Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.19'

- name: Dependencies
run: go mod download

- name: Vet
run: ./vet.sh

- name: Build
run: go build -v ./cmd/cayley

- name: Test
run: go test -v ./...

release:
name: Release
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/') || (github.ref == 'refs/heads/ci_tests')
needs:
- tests
steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.19'

- name: Dependencies
run: go mod download

- name: Download UI
run: go run cmd/download_ui/download_ui.go

- name: Run Packr
run: |
go run github.com/gobuffalo/packr/v2/packr2
git checkout -- ./packrd/dummy.go
- name: Release
uses: goreleaser/goreleaser-action@v4
if: startsWith(github.ref, 'refs/tags/v')
with:
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

docker:
name: Docker image
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/') || (github.ref == 'refs/heads/master') || (github.ref == 'refs/heads/ci_tests')
needs:
- tests

steps:
- uses: actions/checkout@v3

- name: Docker build
run: |
docker build -t $DOCKER_IMAGE_NAME:dev --build-arg VERSION=${{ github.ref_name }} .
- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
if: startsWith(github.ref, 'refs/tags/') || (github.ref == 'refs/heads/master')
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Push latest
if: (github.ref == 'refs/heads/master')
run: |
docker push $DOCKER_IMAGE_NAME:dev
- name: Push tagged
if: startsWith(github.ref, 'refs/tags/')
run: |
docker tag $DOCKER_IMAGE_NAME:dev $DOCKER_IMAGE_NAME:${{ github.ref_name }}
docker push $DOCKER_IMAGE_NAME:${{ github.ref_name }}
- name: Push latest
if: startsWith(github.ref, 'refs/tags/v')
run: |
docker tag $DOCKER_IMAGE_NAME:dev $DOCKER_IMAGE_NAME:latest
docker push $DOCKER_IMAGE_NAME:latest
22 changes: 0 additions & 22 deletions .github/workflows/tests.yml

This file was deleted.

3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ addons:
- snapd

go:
- "1.13.x"
- "1.17.x"
- "1.19.x"
- tip

matrix:
Expand Down
12 changes: 7 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
FROM golang:1.13 as builder
FROM golang:1.19 as builder

ARG VERSION=v0.8.x-dev

# Install packr
RUN go get -u github.com/gobuffalo/packr/v2/packr2
RUN go install github.com/gobuffalo/packr/v2/packr2@latest

# Create filesystem for minimal image
WORKDIR /fs
Expand All @@ -10,7 +12,7 @@ RUN mkdir -p etc/ssl/certs lib/x86_64-linux-gnu tmp bin data; \
# Copy CA Certificates
cp /etc/ssl/certs/ca-certificates.crt etc/ssl/certs/ca-certificates.crt; \
# Copy C standard library
cp /lib/x86_64-linux-gnu/libc-* lib/x86_64-linux-gnu/
cp /lib/x86_64-linux-gnu/libc.* lib/x86_64-linux-gnu/

# Set up workdir for compiling
WORKDIR /src
Expand All @@ -30,9 +32,9 @@ ADD . .
RUN packr2

# Pass a Git short SHA as build information to be used for displaying version
RUN SHORT_SHA=$(git rev-parse --short=12 HEAD); \
RUN GIT_SHA=$(git rev-parse --short=12 HEAD); \
go build \
-ldflags="-linkmode external -extldflags -static -X github.com/cayleygraph/cayley/version.GitHash=$SHORT_SHA" \
-ldflags="-linkmode external -extldflags -static -X github.com/cayleygraph/cayley/version.Version=$VERSION -X github.com/cayleygraph/cayley/version.GitHash=$GIT_SHA" \
-a \
-installsuffix cgo \
-o /fs/bin/cayley \
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
</a>
</div>

[![Build Status](https://api.travis-ci.com/cayleygraph/cayley.svg?branch=master)](https://app.travis-ci.com/github/cayleygraph/cayley)
![Tests](https://github.com/cayleygraph/cayley/actions/workflows/build-and-release.yml/badge.svg)
[![Container Repository](https://img.shields.io/docker/cloud/build/cayleygraph/cayley "Container Repository")](https://hub.docker.com/r/cayleygraph/cayley)

Cayley is an open-source database for [Linked Data](https://www.w3.org/standards/semanticweb/data). It is inspired by the graph database behind Google's [Knowledge Graph](https://en.wikipedia.org/wiki/Knowledge_Graph) (formerly [Freebase](https://en.wikipedia.org/wiki/Freebase_(database))).
Expand Down
2 changes: 1 addition & 1 deletion vet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ IGNORED_PATTERNS=(
"^# "

# Field order is well-defined
"/quad\.Quad composite literal uses unkeyed fields"
"/quad\.Quad struct literal uses unkeyed fields"

# Code imported from b
" method Seek\(k int64\) .* should have signature "
Expand Down

0 comments on commit c318932

Please sign in to comment.