Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor tegola_lambda CI to use Amazon Linux for building #790

Merged
merged 1 commit into from
Jul 21, 2021
Merged
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
22 changes: 22 additions & 0 deletions .github/actions/amazon-linux-build-action/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Amazon Linux is used to build tegola_linux so the CGO requirements are linked correctly
FROM amazonlinux:latest
ARolek marked this conversation as resolved.
Show resolved Hide resolved

# install build deps
RUN yum install -y tar gzip gcc

# install Go
ENV GOLANG_VERSION 1.16.6
ENV GOLANG_VERSION_SHA256 be333ef18b3016e9d7cb7b1ff1fdb0cac800ca0be4cf2290fe613b3d069dfe0d

RUN curl -o golang.tar.gz https://dl.google.com/go/go$GOLANG_VERSION.linux-amd64.tar.gz \
&& echo "$GOLANG_VERSION_SHA256 golang.tar.gz" | sha256sum --strict --check \
&& tar -C /usr/local -xzf golang.tar.gz \
&& rm golang.tar.gz

ENV PATH /usr/local/go/bin:$PATH

# entrypoint.sh holds the build instructions for tegola_lambda
COPY entrypoint.sh /entrypoint.sh

# run the build script when this container starts up
ENTRYPOINT ["/entrypoint.sh"]
12 changes: 12 additions & 0 deletions .github/actions/amazon-linux-build-action/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: 'Amazon Linux build container'
description: 'Used for building tegola_lambda'
inputs:
args:
description: 'Should always be three dots'
required: true
default: '...'
runs:
using: 'docker'
image: 'Dockerfile'
args:
- ${{ inputs.args }}
22 changes: 22 additions & 0 deletions .github/actions/amazon-linux-build-action/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/sh -l

# This file expects to run in a Docker container running on GitHub Actions.
# GitHub will automatically mount the source code directory as a Docker volume
# using the following docker run flag:
#
# -v "/home/runner/work/tegola/tegola":"/github/workspace"
#
# The workdir is set using the following docker run flag:
#
# --workdir /github/workspace
#
# The VERSION env var is set using the following docker run flag:
#
# -e VERSION
#

# move to the tegola_lambda folder
cd cmd/tegola_lambda

# build the binary
go build -mod vendor -ldflags "-w -X main.Version=$VERSION"
2 changes: 1 addition & 1 deletion .github/workflows/on_pr_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ jobs:

test:
name: Test on Ubuntu
runs-on: ubuntu-latest
runs-on: ubuntu-20.04

services:
# label used to access the service container
Expand Down
40 changes: 27 additions & 13 deletions .github/workflows/on_release_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:

gen_version:
name: Generate software version
runs-on: ubuntu-latest
runs-on: ubuntu-20.04

steps:
# on release we want to use release.tag_name for the version
Expand All @@ -22,15 +22,15 @@ jobs:
run: echo ${{ github.sha }} | cut -c1-7 > ${{ github.workspace }}/version.txt

- name: Upload build artifacts
uses: actions/upload-artifact@v2-preview
uses: actions/upload-artifact@v2
with:
name: version
path: ${{ github.workspace }}/version.txt

build_linux:
name: Build for Linux and AWS Lambda
needs: gen_version
runs-on: ubuntu-latest
runs-on: ubuntu-20.04

steps:
- name: Check out code
Expand Down Expand Up @@ -65,7 +65,7 @@ jobs:
zip -9 -D tegola.zip tegola

- name: Upload build artifacts
uses: actions/upload-artifact@v2-preview
uses: actions/upload-artifact@v2
with:
name: tegola_linux_amd64
path: cmd/tegola/tegola.zip
Expand All @@ -81,13 +81,27 @@ jobs:
asset_name: tegola_linux_amd64.zip
asset_content_type: application/zip

build_tegola_lambda:
name: Build tegola_lambda on Amazon Linux
needs: gen_version
runs-on: ubuntu-20.04

steps:
- name: Check out code
uses: actions/checkout@v2

- name: Download version artifact
uses: actions/download-artifact@v1
with:
name: version

- name: Set tegola version
run: echo "VERSION=$(cat version/version.txt)" >> $GITHUB_ENV

- name: Build tegola_lambda
env:
# build architecture
GOOS: linux
run: |
cd cmd/tegola_lambda
go build -mod vendor -ldflags "-w -X main.Version=${VERSION}"
uses: ./.github/actions/amazon-linux-build-action
with:
args: '...'

# workaround for archives losing permissions
# https://github.com/actions/upload-artifact/issues/38
Expand All @@ -97,7 +111,7 @@ jobs:
zip -9 -D tegola.zip tegola_lambda

- name: Upload build artifacts
uses: actions/upload-artifact@v2-preview
uses: actions/upload-artifact@v2
with:
name: tegola_lambda
path: cmd/tegola_lambda/tegola.zip
Expand Down Expand Up @@ -150,7 +164,7 @@ jobs:
zip -9 -D tegola.zip tegola

- name: Upload build artifacts
uses: actions/upload-artifact@v2-preview
uses: actions/upload-artifact@v2
with:
name: tegola_darwin_amd64
path: cmd/tegola/tegola.zip
Expand All @@ -169,7 +183,7 @@ jobs:
build_docker:
name: Build Docker image and publish to Docker Hub
needs: gen_version
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
env:
DOCKERHUB_ORG: gospatial
DOCKERHUB_REPO: tegola
Expand Down