1.5.3 #47
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish Docker images | |
on: | |
release: | |
types: [published] | |
workflow_dispatch: | |
jobs: | |
push_to_dockerhub: | |
runs-on: ubuntu-20.04 | |
env: | |
GO111MODULE: on | |
CGO_ENABLED: "0" | |
GOFLAGS: "-mod=vendor" | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install system deps | |
run: | | |
sudo apt-get update | |
sudo apt-get install bison | |
- uses: actions/cache@v1 | |
with: | |
path: vendor | |
key: vendor-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
vendor- | |
- run: go mod vendor | |
- name: Build mruby | |
run: bash -c '(cd vendor/github.com/mitchellh/go-mruby && MRUBY_CONFIG=../../../../../../etc/build_config.rb make libmruby.a)' | |
- uses: actions/setup-go@v4 | |
with: | |
go-version-file: go.mod | |
- name: Set VERSION (if any) | |
if: ${{ contains(github.ref, 'refs/tags/v') }} | |
id: version | |
run: | | |
echo VERSION=${GITHUB_REF#refs/tags/v} >> $GITHUB_OUTPUT | |
- name: Prepare files for Docker build | |
run: | | |
cp /etc/ssl/certs/ca-certificates.crt ./.docker/ca-certificates.crt | |
- name: Build binary | |
run: | | |
env GOOS=linux GOARCH=arm64 go build -ldflags "-s -w -X github.com/anycable/anycable-go/version.version=${{ steps.version.outputs.VERSION }} -X github.com/anycable/anycable-go/version.sha=$(echo "$GITHUB_SHA" | cut -c -7)" -a -o .docker/linux/arm64/anycable-go cmd/anycable-go/main.go | |
env GOOS=linux GOARCH=amd64 go build -ldflags "-s -w -X github.com/anycable/anycable-go/version.version=${{ steps.version.outputs.VERSION }} -X github.com/anycable/anycable-go/version.sha=$(echo "$GITHUB_SHA" | cut -c -7)" -a -o .docker/linux/amd64/anycable-go cmd/anycable-go/main.go | |
.docker/linux/amd64/anycable-go -v | |
- uses: docker/setup-buildx-action@v2 | |
- uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Prepare Docker metadata and versions | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
flavor: | | |
latest=auto | |
images: | | |
anycable/anycable-go | |
tags: | | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
type=semver,pattern={{major}} | |
type=sha,prefix= | |
type=edge,branch=master | |
- name: Build and push base images | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
file: .docker/Dockerfile.universal | |
push: true | |
platforms: linux/amd64,linux/arm64 | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: | | |
maintainer=Vladimir Dementyev | |
org.opencontainers.image.description=AnyCable WebSocket server | |
org.opencontainers.image.vendor=Evil Martians | |
org.opencontainers.image.url=https://anycable.io | |
org.opencontainers.image.source=https://github.com/anycable/anycable-go | |
org.opencontainers.image.documentation=https://docs.anycable.io | |
org.opencontainers.image.licenses=MIT | |
- name: Prepare Docker metadata and versions for alpine image | |
id: meta-alpine | |
uses: docker/metadata-action@v3 | |
with: | |
flavor: | | |
latest=auto | |
prefix= | |
suffix=-alpine,onlatest=true | |
images: | | |
anycable/anycable-go | |
tags: | | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
type=semver,pattern={{major}} | |
type=sha,prefix= | |
type=edge,branch=master | |
- name: Build and push alpine images | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
file: .docker/Dockerfile.alpine | |
push: true | |
platforms: linux/amd64,linux/arm64 | |
tags: ${{ steps.meta-alpine.outputs.tags }} | |
labels: | | |
maintainer=Vladimir Dementyev | |
org.opencontainers.image.description=AnyCable WebSocket server | |
org.opencontainers.image.vendor=Evil Martians | |
org.opencontainers.image.url=https://anycable.io | |
org.opencontainers.image.source=https://github.com/anycable/anycable-go | |
org.opencontainers.image.documentation=https://docs.anycable.io | |
org.opencontainers.image.licenses=MIT | |
- name: Build binary with MRuby | |
env: | |
CGO_ENABLED: "1" | |
run: | | |
env GOOS=linux GOARCH=amd64 go build -tags mrb -ldflags "-s -w -X github.com/anycable/anycable-go/version.version=${{ steps.version.outputs.VERSION }} -X github.com/anycable/anycable-go/version.sha=$(echo "$GITHUB_SHA" | cut -c -7)" -a -o .docker/linux/amd64/anycable-go cmd/anycable-go/main.go | |
.docker/linux/amd64/anycable-go -v | |
- name: Prepare Docker metadata and versions for mrb image | |
id: meta-mrb | |
uses: docker/metadata-action@v3 | |
with: | |
flavor: | | |
latest=auto | |
prefix= | |
suffix=-mrb,onlatest=true | |
images: | | |
anycable/anycable-go | |
tags: | | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
type=semver,pattern={{major}} | |
type=sha,prefix= | |
type=edge,branch=master | |
- name: Build and push mrb images | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
file: .docker/Dockerfile.mrb-linux-amd64 | |
push: true | |
tags: ${{ steps.meta-mrb.outputs.tags }} | |
labels: | | |
maintainer=Vladimir Dementyev | |
org.opencontainers.image.description=AnyCable WebSocket server | |
org.opencontainers.image.vendor=Evil Martians | |
org.opencontainers.image.url=https://anycable.io | |
org.opencontainers.image.source=https://github.com/anycable/anycable-go | |
org.opencontainers.image.documentation=https://docs.anycable.io | |
org.opencontainers.image.licenses=MIT |