Skip to content

Commit

Permalink
chore: refactor workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
le0m committed Aug 7, 2024
1 parent d490900 commit b63fcfb
Show file tree
Hide file tree
Showing 8 changed files with 221 additions and 151 deletions.
28 changes: 12 additions & 16 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,30 @@
version: 2
updates:

# Maintain dependencies for print2pdf package
# Maintain dependencies for go modules
- package-ecosystem: "gomod"
directory: "/print2pdf"
directories:
- "/print2pdf"
- "/plain"
- "/lambda"
schedule:
interval: "weekly"
groups:
aws:
patterns: ['github.com/aws/*']
chromedp:
patterns: ['github.com/chromedp/*']
# Maintain self-dependencies for plain module
- package-ecosystem: "gomod"
directory: "/plain"
schedule:
interval: "weekly"
groups:
chialab:
patterns: ['github.com/chialab/*']
# Maintain self-dependencies for lambda module
- package-ecosystem: "gomod"
directory: "/lambda"
chromedp:
patterns: ['github.com/chromedp/*']

# Maintain dependencies for Terraform module
- package-ecosystem: "terraform"
directory: "/terraform"
schedule:
interval: "weekly"
groups:
aws:
patterns: ['github.com/aws/*']
chialab:
patterns: ['github.com/chialab/*']
patterns: ['aws']

# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/dependency-submission.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
name: "Go Dependency Submission"
name: Dependency Submission

on:
push:
branches: [ main ]
paths:
- '**.go'
- '**.go.mod'
- '**.go.sum'

permissions:
contents: write

jobs:
go-action-detection:
dependency-submission:
name: Submit dependencies
runs-on: ubuntu-latest
timeout-minutes: 5
Expand Down
26 changes: 0 additions & 26 deletions .github/workflows/publish-package.yml

This file was deleted.

51 changes: 0 additions & 51 deletions .github/workflows/release-binaries.yml

This file was deleted.

56 changes: 0 additions & 56 deletions .github/workflows/release-containers.yml

This file was deleted.

126 changes: 126 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
name: Release

on:
push:
tags: [ v*, print2pdf/v* ]

jobs:
release-package:
name: Release GO package
if: ${{ startsWith(github.ref_name, 'print2pdf/v') }}
runs-on: ubuntu-latest
timeout-minutes: 5

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
cache-dependency-path: print2pdf/go.sum
go-version-file: print2pdf/go.mod

- name: Publish package
env:
GOPROXY: proxy.golang.org
TAG: ${{ github.ref_name }}
run: go list -m "github.com/chialab/print2pdf-go/print2pdf@${TAG#print2pdf/}"

release-binaries:
name: Build and release binaries
if: ${{ startsWith(github.ref_name, 'v') }}
runs-on: ubuntu-latest
permissions:
contents: write
timeout-minutes: 5
strategy:
matrix:
module: ['plain', 'lambda']

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
cache-dependency-path: ${{ matrix.module }}/go.sum
go-version-file: ${{ matrix.module }}/go.mod

- name: Build
env:
CGO_ENABLED: 0
run: |
GOOS=linux GOARCH=amd64 go build -C ${{ matrix.module }} -ldflags '-s' -o ../build/print2pdf-${{ matrix.module }}-linux-amd64
GOOS=linux GOARCH=arm64 go build -C ${{ matrix.module }} -ldflags '-s' -o ../build/print2pdf-${{ matrix.module }}-linux-arm64
GOOS=darwin GOARCH=amd64 go build -C ${{ matrix.module }} -ldflags '-s' -o ../build/print2pdf-${{ matrix.module }}-darwin-amd64
GOOS=darwin GOARCH=arm64 go build -C ${{ matrix.module }} -ldflags '-s' -o ../build/print2pdf-${{ matrix.module }}-darwin-arm64
GOOS=windows GOARCH=amd64 go build -C ${{ matrix.module }} -ldflags '-s' -o ../build/print2pdf-${{ matrix.module }}-windows-amd64
GOOS=windows GOARCH=arm64 go build -C ${{ matrix.module }} -ldflags '-s' -o ../build/print2pdf-${{ matrix.module }}-windows-arm64
- name: Release
uses: softprops/action-gh-release@v2
with:
draft: true
generate_release_notes: true
files: |
build/print2pdf-${{ matrix.module }}-linux-amd64
build/print2pdf-${{ matrix.module }}-linux-arm64
build/print2pdf-${{ matrix.module }}-darwin-amd64
build/print2pdf-${{ matrix.module }}-darwin-arm64
build/print2pdf-${{ matrix.module }}-windows-amd64
build/print2pdf-${{ matrix.module }}-windows-arm64
release-containers:
name: Build and release containers
if: ${{ startsWith(github.ref_name, 'v') }}
runs-on: ubuntu-latest
permissions:
contents: write
timeout-minutes: 5
strategy:
matrix:
module: ['plain', 'lambda']

steps:
- name: Checkout
uses: actions/checkout@v4

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

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

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/chialab/print2pdf
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
flavor: |
suffix=-${{ matrix.module }}
latest=false
- name: Login to GitHub Packages
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v6
with:
context: ${{ matrix.module }}
file: ${{ matrix.module }}/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
Loading

0 comments on commit b63fcfb

Please sign in to comment.