Skip to content

Release

Release #9

Workflow file for this run

name: Release
on:
workflow_dispatch:
push:
tags:
- "[0-9]+.[0-9]+.[0-9]+"
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-tags: true
filter: blob:none
fetch-depth: 0
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
# list of Docker images to use as base name for tags
images: |
ghcr.io/${{ github.repository }}
# generate Docker tags based on the following events/attributes
tags: |
type=schedule
type=raw,value=latest,enable={{is_default_branch}}
type=semver,pattern={{version}},value=${{ steps.checkout.outputs.tag }}
type=semver,pattern={{major}}.{{minor}},value=${{ steps.checkout.outputs.tag }}
type=semver,pattern={{major}},value=${{ steps.checkout.outputs.tag }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Set Up containerd image store
shell: bash
run: |
cat /etc/docker/daemon.json | jq '. | .+{"features": {"containerd-snapshotter": true}}' | sudo tee /etc/docker/daemon.json
sudo systemctl restart docker
- name: Login to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Prepare artifacts
run: |
mkdir -p artifacts
mkdir -p out
- name: Build and publish
id: build
uses: docker/build-push-action@v5
with:
context: .
push: true
file: Containerfile
platforms: linux/amd64,linux/arm64/v8,linux/arm/v7
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
outputs: |
type=local,dest=out
type=docker
- name: Copy artifacts
run: |
for k in $(ls out/); do
ARCH=$(basename $k)
echo $ARCH
if [ -f out/$k/usr/local/bin/mollysocket ]; then
cp out/$k/usr/local/bin/mollysocket artifacts/mollysocket-$ARCH
fi
done
- name: Archive artifact
uses: actions/upload-artifact@v2
with:
name: artifacts
path: |
./artifacts
publish:
name: Publish
needs: build
runs-on: ubuntu-latest
if: ${{ startsWith(github.ref, 'refs/tags/') }}
steps:
- uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v3
- name: Create release draft
run: gh release create -d -t "$GITHUB_REF_NAME" "$GITHUB_REF_NAME" ./artifacts/*
env:
GITHUB_TOKEN: ${{ secrets.PUBLISH_PAT || secrets.GITHUB_TOKEN }}