Skip to content

Commit

Permalink
Update packaging and CLI libaries
Browse files Browse the repository at this point in the history
  • Loading branch information
wrouesnel committed Aug 27, 2024
1 parent d1c0bad commit 1ad6f3e
Show file tree
Hide file tree
Showing 61 changed files with 1,797 additions and 10,966 deletions.
13 changes: 13 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Set update schedule for GitHub Actions
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
# Check for updates to GitHub Actions every weekday
interval: "daily"
- package-ecosystem: "gomod"
directory: "/"
schedule:
# Check for updates to GitHub Actions every weekday
interval: "weekly"
72 changes: 72 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: [ "main" ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ "main" ]
schedule:
- cron: '23 7 * * 0'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'go' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

steps:
- name: Checkout repository
uses: actions/checkout@v3

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality


# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.

# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
71 changes: 71 additions & 0 deletions .github/workflows/container.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
name: Container Build
on:
workflow_run:
workflows:
- Build and Test
types:
- completed
branches:
- main
push:
tags:
- v*

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
container-build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Fetch tags
run: git fetch --prune --unshallow --tags -f

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2

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

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
# set latest tag for default branch
type=raw,value=latest,enable={{is_default_branch}}
type=schedule
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=ref,event=branch
type=ref,event=pr
type=sha
type=sha,format=long
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

96 changes: 96 additions & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
---
name: Build and Test
"on":
push:
branches:
- "*"
tags:
- v*
pull_request:
branches:
- "*"
workflow_call:
jobs:
style:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: 1.23
- name: Check style
run: go run mage.go style

# lint:
# runs-on: ubuntu-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v3
# - name: Setup Go
# uses: actions/setup-go@v4
# with:
# go-version: 1.23
# - name: Lint
# run: go run mage.go lint

test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: 1.23
- name: Test
run: go run mage.go test
- name: Merge Coverage Files
run: go run mage.go coverage
- name: Coveralls
uses: shogo82148/actions-goveralls@v1
with:
path-to-profile: .cover.out

build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: 1.23
- name: Build
run: go run mage.go binary

# deploy:
# runs-on: ubuntu-latest
# needs:
# - build
# steps:
# - name: Checkout
# uses: actions/checkout@v3
# with:
# fetch-depth: 0
# - name: Setup Go
# uses: actions/setup-go@v2
# - name: Build Release
# run: make -j$(cat /proc/cpuinfo | grep processor | wc -l) release
# - name: Release
# uses: softprops/action-gh-release@v1
# if: startsWith(github.ref, 'refs/tags/r')
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# files: |
# callback-linux-arm.tar.gz
# callback-linux-arm64.tar.gz
# callback-linux-x86_64.tar.gz
# callback-linux-i386.tar.gz
# callback-windows-i386.zip
# callback-windows-x86_64.zip
# callback-darwin-x86_64.tar.gz
# callback-darwin-arm64.tar.gz
# callback-freebsd-x86_64.tar.gz
75 changes: 75 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
---
name: Release
on:
push:
tags:
- v*

jobs:
integration:
uses: ./.github/workflows/integration.yml

generate-release-matrix:
runs-on: ubuntu-latest
outputs:
release-matrix: ${{ steps.generate-matrix.outputs.release-matrix }}
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: 1.23

- name: Generate Release Matrix
id: generate-matrix
run: go run mage.go githubReleaseMatrix

release-build:
runs-on: ubuntu-latest
needs:
- integration
- generate-release-matrix
strategy:
matrix:
osarch: ${{ fromJson(needs.generate-release-matrix.outputs.release-matrix) }}
max-parallel: 10
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Fetch tags
run: git fetch --prune --unshallow --tags -f

- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: 1.23

- name: Release Build
run: go run mage.go release ${{ matrix.osarch }}

- uses: actions/upload-artifact@v3
with:
name: release
path: release/*

release:
runs-on: ubuntu-latest
needs:
- release-build
steps:
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: release
path: release

- name: Release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: |
release/*
12 changes: 11 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,12 @@
/email
/.idea
.idea
node_modules
/bin
/.bin
/.coverage
/release
/.cover.out
/test-configs
/.junit
/image.iid
/..bfg-report
14 changes: 0 additions & 14 deletions .travis.yml

This file was deleted.

27 changes: 27 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
FROM golang:1.23 AS build

RUN mkdir /build

WORKDIR /build

COPY ./ ./

RUN go run mage.go binary

RUN useradd -u 1001 app \
&& mkdir /config \
&& chown app:root /config

FROM scratch

COPY --from=build /build/email /bin/email
COPY --from=build /etc/passwd /etc/passwd
COPY --from=build /config /

ENV PATH=/bin:$PATH

ENTRYPOINT ["email"]

USER 1001

CMD []
Loading

0 comments on commit 1ad6f3e

Please sign in to comment.