Skip to content

release-containers #134

release-containers

release-containers #134

name: release-containers
on:
release:
types:
- "published"
jobs:
publish-container-images:
name: publish-container-images
runs-on: ubuntu-latest
strategy:
matrix:
base-image:
- scratch
- erlang
- erlang-slim
- erlang-alpine
- elixir
- elixir-slim
- elixir-alpine
- node
- node-slim
- node-alpine
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Authenticate with GitHub container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: lpil
password: ${{ secrets.CONTAINER_REGISTRY_PERSONAL_ACCESS_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build version and tags
id: versions
run: |
# Strip git ref prefix from version
V_VERSION=$(echo "${{ github.ref }}" | sed -e 's|.*/\(.*\)|\1|')
# Strip `v` prefix from version
BARE_VERSION=$(echo "$V_VERSION" | sed -e 's|^v/\(.*\)|\1|')
# Build version with platform
PLATFORM_VERSION=$BARE_VERSION-${{ matrix.base-image }}
# Build container tag
TAG=ghcr.io/${{ github.repository }}:$PLATFORM_VERSION
echo "v_version=$V_VERSION" >> $GITHUB_OUTPUT
echo "bare_version=$BARE_VERSION" >> $GITHUB_OUTPUT
echo "platform_version=$PLATFORM_VERSION" >> $GITHUB_OUTPUT
echo "container_tag=$TAG" >> $GITHUB_OUTPUT
- name: Download Gleam archives from GitHub release
run: |
VERSION=${{ steps.versions.outputs.v_version }}
AMD_URL=https://github.com/${{ github.repository }}/releases/download/$VERSION/gleam-$VERSION-x86_64-unknown-linux-musl.tar.gz
ARM_URL=https://github.com/${{ github.repository }}/releases/download/$VERSION/gleam-$VERSION-aarch64-unknown-linux-musl.tar.gz
echo Downloading amd $AMD_URL
curl -Lo gleam-amd.tar.gz $AMD_URL
echo Downloading arm $ARM_URL
curl -Lo gleam-arm.tar.gz $ARM_URL
- name: Unpack Gleam binary from archive
run: |
tar xf gleam-amd.tar.gz
mv gleam gleam-amd64
tar xf gleam-arm.tar.gz
mv gleam gleam-arm64
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
file: containers/${{ matrix.base-image }}.dockerfile
push: true
tags: ${{ steps.versions.outputs.container_tag }}
labels: |
org.opencontainers.image.title=gleam
org.opencontainers.image.url=https://gleam.run
org.opencontainers.image.source=https://github.com/gleam-lang/gleam
org.opencontainers.image.version=${{ steps.versions.outputs.platform_version }}
org.opencontainers.image.licenses=Apache-2.0