Skip to content

Merge pull request #7 from chialab/running-function #1

Merge pull request #7 from chialab/running-function

Merge pull request #7 from chialab/running-function #1

Workflow file for this run

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 }}