mirror of https://github.com/nealey/vail.git
Trying to set up CI builds
This commit is contained in:
parent
54439e3608
commit
f98a700f10
|
@ -0,0 +1,47 @@
|
|||
name: Build/Push
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- master
|
||||
tags:
|
||||
- v*
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
name: Publish container images
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Retrieve code
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Gitlab variables
|
||||
id: vars
|
||||
run: build/gitlab-vars
|
||||
|
||||
- name: Login to GitHub Packages Docker Registry
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.repository_owner }}
|
||||
password: ${{ secrets.CR_PAT }}
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v1
|
||||
|
||||
# Currently required, because buildx doesn't support auto-push from docker
|
||||
- name: Set up builder
|
||||
uses: docker/setup-buildx-action@v1
|
||||
id: buildx
|
||||
|
||||
- name: Build and push moth image
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
builder: ${{ steps.buildx.outputs.name }}
|
||||
target: moth
|
||||
file: build/Dockerfile
|
||||
push: true
|
||||
platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le
|
||||
tags: |
|
||||
ghcr.io/nealey/vail:${{ steps.vars.outputs.tag }}
|
|
@ -0,0 +1,9 @@
|
|||
# Changelog
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Calendar Versioning](https://calver.org/).
|
||||
|
||||
## [2021-07-31]
|
||||
## Added
|
||||
- Now builds as a docker image
|
|
@ -2,7 +2,8 @@ FROM golang:1 AS builder
|
|||
|
||||
COPY . /src
|
||||
COPY static /target/static
|
||||
RUN CGO_ENABLED=0 GOOS=linux go install -i -a -ldflags '-extldflags "-static"' /src/...
|
||||
WORKDIR /src
|
||||
RUN CGO_ENABLED=0 GOOS=linux go install -a -ldflags '-extldflags "-static"' ./...
|
||||
RUN cp -r /go/bin /target
|
||||
|
||||
FROM scratch
|
|
@ -0,0 +1,15 @@
|
|||
#! /bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
cd $(dirname $0)/..
|
||||
|
||||
target=vail
|
||||
VERSION=$(cat CHANGELOG.md | awk -F '[][]' '/^## \[/ {print $2; exit}')
|
||||
tag=nealey/$target:$VERSION
|
||||
|
||||
echo "==== Building $tag"
|
||||
docker build \
|
||||
--tag $tag \
|
||||
-f build/Dockerfile \
|
||||
.
|
|
@ -0,0 +1,25 @@
|
|||
#! /bin/sh
|
||||
|
||||
case $1 in
|
||||
-h|-help|--help)
|
||||
echo "Usage: $0 TARGET"
|
||||
echo
|
||||
echo "Sets CI build variables for gitlab"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
branch=$(git symbolic-ref -q --short HEAD)
|
||||
if [ "$branch" = "main" ]; then
|
||||
branch=latest
|
||||
fi
|
||||
|
||||
printf "Branch: %s\n" "$branch"
|
||||
printf "::set-output name=branch::%s\n" "$branch"
|
||||
printf "::set-output name=tag::%s\n" "$branch"
|
||||
|
||||
# I think it will use whichever comes last
|
||||
git tag --points-at HEAD | while read tag; do
|
||||
printf "Tag: %s\n" "$tag"
|
||||
printf "::set-output name=tag::%s\n" "$tag"
|
||||
done
|
Loading…
Reference in New Issue