1.5.1 #16
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: Release | |
on: | |
workflow_dispatch: | |
push: | |
tags: | |
- "[0-9]+.[0-9]+.[0-9]+" | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
flavor: ['debian', 'alpine'] | |
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 }} | |
# add flavor to set latest to false and add those with raw values instead | |
flavor: | | |
latest=false | |
prefix= | |
suffix= | |
# generate Docker tags based on the following events/attributes | |
tags: | | |
type=schedule | |
type=raw,value=latest,enable=${{matrix.flavor == 'debian'}} | |
type=raw,value=latest-${{matrix.flavor}} | |
type=semver,pattern={{version}},value=${{ steps.checkout.outputs.tag }},enable=${{matrix.flavor == 'debian'}} | |
type=semver,pattern={{major}}.{{minor}},value=${{ steps.checkout.outputs.tag }},enable=${{matrix.flavor == 'debian'}} | |
type=semver,pattern={{major}},value=${{ steps.checkout.outputs.tag }},enable=${{matrix.flavor == 'debian'}} | |
type=semver,pattern={{version}}-${{matrix.flavor}},value=${{ steps.checkout.outputs.tag }} | |
type=semver,pattern={{major}}.{{minor}}-${{matrix.flavor}},value=${{ steps.checkout.outputs.tag }} | |
type=semver,pattern={{major}}-${{matrix.flavor}},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-${{ matrix.flavor }} | |
mkdir -p out | |
- name: Build and publish | |
id: build | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: true | |
file: Containerfile.${{ matrix.flavor }} | |
platforms: linux/amd64,linux/arm64/v8${{ matrix.flavor == 'debian' && ',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) | |
if [[ "${{ matrix.flavor }}" == "alpine" ]]; then | |
ARCH="musl-$ARCH" | |
fi | |
echo $ARCH | |
if [ -f out/$k/usr/local/bin/mollysocket ]; then | |
cp out/$k/usr/local/bin/mollysocket artifacts-${{ matrix.flavor }}/mollysocket-$ARCH | |
fi | |
done | |
- name: Archive artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: artifacts-${{ matrix.flavor }} | |
path: | | |
./artifacts-${{ matrix.flavor }} | |
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@v4 | |
with: | |
path: artifacts | |
pattern: artifacts-* | |
merge-multiple: true | |
- run: ls -R ./artifacts | |
- 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 }} |