Merge pull request #3 from secondlife/signal/dependabot-docker #19
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: CI | |
on: | |
pull_request: | |
push: | |
branches: [main] | |
tags: [v*] | |
permissions: | |
contents: write | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v5 | |
with: | |
go-version: ~1.22 | |
- name: Lint | |
uses: secondlife-3p/golangci-lint-action@v5 | |
with: | |
version: latest | |
- name: Test | |
run: | | |
go mod tidy | |
go test -v | |
build-image: | |
runs-on: ubuntu-latest | |
needs: test | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: lindenlab/debserve | |
tags: | | |
type=ref,event=branch | |
type=ref,event=pr | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
type=semver,pattern={{major}} | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
if: startsWith(github.ref, 'refs/tags/v') | |
with: | |
username: ${{ secrets.SHARED_DOCKERHUB_USER }} | |
password: ${{ secrets.SHARED_DOCKERHUB_TOKEN }} | |
- name: Build and push | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
push: ${{ startsWith(github.ref, 'refs/tags/v') }} | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
platforms: linux/amd64,linux/arm64 | |
- name: Docker Hub Description | |
uses: secondlife-3p/dockerhub-description@v4 | |
if: startsWith(github.ref, 'refs/tags/v') | |
with: | |
username: ${{ secrets.SHARED_DOCKERHUB_USER }} | |
password: ${{ secrets.SHARED_DOCKERHUB_TOKEN }} | |
repository: lindenlab/debserve | |
short-description: Self-contained debian package server | |
build-package: | |
runs-on: ubuntu-latest | |
needs: test | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Choose GoReleaser args | |
shell: bash | |
env: | |
IS_TAG: ${{ startsWith(github.ref, 'refs/tags/v') }} | |
id: goreleaser-args | |
run: | | |
if [[ "$IS_TAG" == "true" ]] | |
then | |
echo "Building for a tag: do a fully regular gorelease" >&2 | |
echo "value=" >> $GITHUB_OUTPUT | |
else | |
echo "Not building for a tag: do the gorelease in snapshot mode" >&2 | |
echo "value=--snapshot" >> $GITHUB_OUTPUT | |
fi | |
- name: Run GoReleaser | |
uses: goreleaser/goreleaser-action@v6 | |
with: | |
version: v1.25.1 | |
args: release ${{ steps.goreleaser-args.outputs.value }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |