Update env var for serverport per recent fix #89
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: | |
- push | |
- pull_request | |
env: | |
DOCKERHUB_USERNAME: druggeri | |
jobs: | |
test: | |
name: Test | |
strategy: | |
matrix: | |
go-version: | |
- 1.18.x | |
os: | |
- ubuntu-latest | |
- macos-latest | |
- windows-latest | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Install Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version: ${{ matrix.go-version }} | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Test | |
run: go test ./... | |
release: | |
needs: test | |
name: Build and release | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Set up Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version: 1.18 | |
- name: Run GoReleaser | |
uses: goreleaser/goreleaser-action@v4 | |
with: | |
distribution: goreleaser | |
version: latest | |
args: build --clean --parallelism=2 --timeout=1h --skip-validate | |
- name: Publish release | |
uses: goreleaser/goreleaser-action@v4 | |
if: startsWith(github.ref, 'refs/tags/v') | |
with: | |
distribution: goreleaser | |
version: latest | |
args: release --clean --parallelism=2 --timeout=1h --release-notes=.release_info.md | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
containers: | |
if: startsWith(github.ref, 'refs/tags/v') | |
needs: release | |
name: Push containers | |
runs-on: ubuntu-latest | |
steps: | |
- name: Prep variables | |
run: | | |
set -u | |
export PROJECT_NAME=${GITHUB_REPOSITORY##*/} | |
export TAG=${GITHUB_REF##*/} | |
echo "PROJECT_NAME=$PROJECT_NAME" >> $GITHUB_ENV | |
echo "TAG=$TAG" >> $GITHUB_ENV | |
echo "URL_LINUX_AMD64=https://github.com/${GITHUB_REPOSITORY}/releases/download/$TAG/${PROJECT_NAME}-${TAG}-linux-amd64" >> $GITHUB_ENV | |
echo "URL_LINUX_ARM64=https://github.com/${GITHUB_REPOSITORY}/releases/download/$TAG/${PROJECT_NAME}-${TAG}-linux-arm64" >> $GITHUB_ENV | |
echo "URL_LINUX_ARM=https://github.com/${GITHUB_REPOSITORY}/releases/download/$TAG/${PROJECT_NAME}-${TAG}-linux-arm" >> $GITHUB_ENV | |
- name: Setup Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Log in to the Container registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Login to DockerHub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ env.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: | | |
${{ env.DOCKERHUB_USERNAME }}/${{ env.PROJECT_NAME }} | |
ghcr.io/${{ github.repository }} | |
tags: | | |
type=ref,event=branch | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
type=sha | |
- name: Create scratch docker image | |
run: | | |
echo " | |
FROM alpine AS builder | |
RUN apk --no-cache add wget ca-certificates \ | |
&& if uname -m | grep 'x86_64' >/dev/null 2>&1; then wget -O /downloaded_file $URL_LINUX_AMD64;fi \ | |
&& if uname -m | grep 'aarch64' >/dev/null 2>&1; then wget -O /downloaded_file $URL_LINUX_ARM64;fi \ | |
&& if uname -m | grep 'arm' >/dev/null 2>&1; then wget -O /downloaded_file $URL_LINUX_ARM;fi \ | |
&& if [ ! -f /downloaded_file ];then echo "===Failed to download for:";uname -m;echo "===";exit 1;fi \ | |
&& chmod 755 /downloaded_file | |
FROM scratch | |
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt | |
COPY --from=builder /downloaded_file /$PROJECT_NAME | |
ENTRYPOINT [\"/$PROJECT_NAME\"] | |
" > Dockerfile | |
echo "Rendered Dockerfile in $PWD:" | |
cat Dockerfile | |
- name: Build and push Docker images | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
platforms: linux/amd64,linux/arm64,linux/arm | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} |