Skip to content

Commit

Permalink
Merge branch 'master' into feature/quill
Browse files Browse the repository at this point in the history
  • Loading branch information
chadweimer committed Oct 7, 2024
2 parents ef7806b + 850df83 commit 020e494
Show file tree
Hide file tree
Showing 71 changed files with 3,231 additions and 1,612 deletions.
5 changes: 1 addition & 4 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@ root = true

[*]
indent_style = space
indent_size = 4
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[{*.go,Makefile}]
indent_style = tab

[{*.json,*.js,*.jsx,*.ts,*.tsx,*.yml,*.yaml,*.css,*.html}]
indent_size = 2
96 changes: 73 additions & 23 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@ on:
release:
types: [published]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

env:
CONTAINER_REGISTRY: ghcr.io
CONTAINER_IMAGE_NAME: ${{ github.repository }}
REPO_NAME: ${{ github.repository }}

jobs:
check:
name: Check
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -24,7 +27,7 @@ jobs:
node-version: "lts/*"
- uses: actions/setup-go@v5
with:
go-version: "1.22.x"
go-version-file: 'go.mod'
- run: make install
- run: make lint test
- uses: actions/upload-artifact@v4
Expand All @@ -39,15 +42,50 @@ jobs:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
build:
name: Build
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
strategy:
matrix:
os: [linux]
arch: [amd64,arm64,arm]
env:
TARGETOS: ${{ matrix.os }}
TARGETARCH: ${{ matrix.arch }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "lts/*"
- uses: actions/setup-go@v5
with:
go-version: "1.22.x"
go-version-file: 'go.mod'

- name: Set env vars (push)
if: github.event_name == 'push'
run: echo "BUILD_VERSION=0.0.0-beta+commit.${{ github.sha }}" >> $GITHUB_ENV
- name: Set env vars (pr)
if: github.event_name == 'pull_request'
run: echo "BUILD_VERSION=0.0.0-pr${{ github.event.pull_request.number }}+commit.${{ github.sha }}" >> $GITHUB_ENV
- name: Set env vars (release)
if: github.event_name == 'release'
run: echo "BUILD_VERSION=${{ github.event.release.tag_name }}" >> $GITHUB_ENV

- name: Build
run: make build archive

- uses: actions/upload-artifact@v4
with:
name: gomp-${{ matrix.os }}-${{ matrix.arch }}-${{ env.BUILD_VERSION }}
path: build/gomp-${{ matrix.os }}-${{ matrix.arch }}-${{ env.BUILD_VERSION }}.tar.gz
compression-level: 0
publish:
name: Publish
needs: build
runs-on: ubuntu-24.04
env:
CONTAINER_REGISTRY: ghcr.io
DOCKER_BASE_ARGS: --push --platform linux/amd64,linux/arm64,linux/arm
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- uses: docker/setup-qemu-action@v3
with:
Expand All @@ -57,24 +95,36 @@ jobs:
registry: ${{ env.CONTAINER_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- run: make install
- run: make build docker BUILD_VERSION="v0.0.0 (master)" CONTAINER_TAG=latest
if: startswith(github.ref, 'refs/heads/master')
- run: make build docker BUILD_VERSION="v0.0.0 ($(echo $GITHUB_REF | sed -e 's/^refs\/pull\///'))" CONTAINER_TAG=dev
if: startswith(github.ref, 'refs/pull/')
- run: make build docker BUILD_VERSION="v$(echo $GITHUB_REF | sed -e 's/^refs\/tags\///')" CONTAINER_TAG="$(echo $GITHUB_REF | sed -e 's/^refs\/tags\///')"
if: startswith(github.ref, 'refs/tags/')
- run: make archive
- uses: actions/upload-artifact@v4
with:
name: artifacts
path: |
build/gomp-*
- uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')

- name: Set env vars (push)
if: github.event_name == 'push'
run: |
echo "BUILD_VERSION=0.0.0-beta+commit.${{ github.sha }}" >> $GITHUB_ENV
echo "DOCKER_ARGS=${{ env.DOCKER_BASE_ARGS }} -t ${{ env.CONTAINER_REGISTRY }}/${{ env.REPO_NAME }}:beta" >> $GITHUB_ENV
- name: Set env vars (pr)
if: github.event_name == 'pull_request'
run: |
echo "BUILD_VERSION=0.0.0-pr${{ github.event.pull_request.number }}+commit.${{ github.sha }}" >> $GITHUB_ENV
echo "DOCKER_ARGS=${{ env.DOCKER_BASE_ARGS }} -t ${{ env.CONTAINER_REGISTRY }}/${{ env.REPO_NAME }}:pr${{ github.event.pull_request.number }}" >> $GITHUB_ENV
- name: Set env vars (release)
if: github.event_name == 'release'
run: |
echo "BUILD_VERSION=${{ github.event.release.tag_name }}" >> $GITHUB_ENV
echo "DOCKER_ARGS=${{ env.DOCKER_BASE_ARGS }} -t ${{ env.CONTAINER_REGISTRY }}/${{ env.REPO_NAME }}:latest -t ${{ env.CONTAINER_REGISTRY }}/${{ env.REPO_NAME }}:${{ github.event.release.tag_name }}" >> $GITHUB_ENV
- name: Download artifacts
uses: actions/download-artifact@v4
with:
files: |
build/gomp-*
path: build
merge-multiple: true

- name: Publish container image
run: make docker

- name: Publish artifacts to release
uses: softprops/action-gh-release@v2
if: github.event_name == 'release'
with:
files: build/*.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8 changes: 8 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
{
"editor.formatOnSave": true,
"editor.renderWhitespace": "boundary",
"go.coverOnSave": true,
"go.coverageOptions": "showUncoveredCodeOnly",
"go.formatTool": "goimports",
"go.inlayHints.assignVariableTypes": true,
"go.inlayHints.functionTypeParameters": true,
"go.inlayHints.parameterNames": true,
"go.inlayHints.rangeVariableTypes": true,
"go.lintTool": "revive",
"go.lintFlags": [
"-config=${workspaceRoot}/revive.toml"
Expand Down
14 changes: 2 additions & 12 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"version": "2.0.0",
"tasks": [
"version": "2.0.0",
"tasks": [
{
"label": "Build",
"type": "shell",
Expand All @@ -20,16 +20,6 @@
"command": "make clean",
"problemMatcher": [],
"group": "build"
},
{
"label": "Build linux/amd64",
"type": "shell",
"command": "make build/linux/amd64",
"problemMatcher": [
"$go",
"$tsc"
],
"group": "build"
}
]
}
15 changes: 8 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
FROM alpine:3.19 AS alpine
ARG TARGETPLATFORM
FROM alpine:3.20 AS alpine

RUN apk add --no-cache ca-certificates

FROM scratch
ARG TARGETPLATFORM
LABEL org.opencontainers.image.source "https://github.com/chadweimer/gomp"
LABEL org.opencontainers.image.title "GOMP: Go Meal Planner"
LABEL org.opencontainers.image.description "Web-based recipe book."
ARG TARGETOS
ARG TARGETARCH
ARG ARCHIVE_SUFFIX
LABEL org.opencontainers.image.source="https://github.com/chadweimer/gomp"
LABEL org.opencontainers.image.title="GOMP: Go Meal Planner"
LABEL org.opencontainers.image.description="Web-based recipe book."

EXPOSE 5000

WORKDIR /var/app/gomp
VOLUME /var/app/gomp/data

COPY --from=alpine /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY build/$TARGETPLATFORM ./
ADD build/gomp-$TARGETOS-$TARGETARCH$ARCHIVE_SUFFIX.tar.gz ./

ENTRYPOINT ["./gomp"]
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2016-2022 Chad Weimer
Copyright (c) 2016-2024 Chad Weimer

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
Loading

0 comments on commit 020e494

Please sign in to comment.