Merge pull request #10 from kha7iq/add-docker-support

Add docker support for multi arch images
pull/11/head
Khaliq 4 years ago committed by GitHub
commit 81d4fcc89e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,29 +1,66 @@
name: goreleaser
name: build
on:
push:
tags:
- '*'
- 'v*'
jobs:
goreleaser:
release-pingme:
runs-on: ubuntu-latest
env:
DOCKER_CLI_EXPERIMENTAL: "enabled"
steps:
-
name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v2.3.4
with:
fetch-depth: 0
-
name: Set up QEMU
uses: docker/setup-qemu-action@v1
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
-
name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16
go-version: '1.16'
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
name: Cache Go modules
uses: actions/cache@v2.1.5
with:
version: latest
args: release --rm-dist
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
-
name: Diff
run: git diff
-
name: Docker Login
if: success() && startsWith(github.ref, 'refs/tags/v')
env:
GITHUB_TOKEN: ${{ secrets.GO_RELEASER_GITHUB_TOKEN }}
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
GITHUB_TOKEN: ${{ secrets.GO_RELEASER_GITHUB_TOKEN }}
run: |
echo "${DOCKER_PASSWORD}" | docker login --username "${DOCKER_USERNAME}" --password-stdin
echo "${GITHUB_TOKEN}" | docker login ghcr.io --username $GITHUB_ACTOR --password-stdin
-
name: GoReleaser
if: success()
env:
GITHUB_TOKEN: ${{ secrets.GO_RELEASER_GITHUB_TOKEN }}
run: |
if [[ $GITHUB_REF == refs/tags/v* ]]; then
./goreleaser
elif [[ $GITHUB_REF == refs/heads/master ]]; then
./goreleaser --snapshot
fi
-
name: Clear
if: always() && startsWith(github.ref, 'refs/tags/v')
run: |
rm -f ${HOME}/.docker/config.json

@ -0,0 +1,6 @@
FROM alpine:latest
ENTRYPOINT ["entrypoint.sh"]
COPY scripts/entrypoint.sh /usr/bin/entrypoint.sh
RUN chmod +x /usr/bin/entrypoint.sh
COPY pingme /usr/bin/pingme

@ -66,4 +66,73 @@ nfpms:
- deb
- rpm
dependencies:
- git
- git
# snapcrafts:
# - name_template: '{{ .ProjectName }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}'
# summary: PingMe is a CLI tool which provides the ability to send messages
# description: |
# PingMe is a CLI tool which provides the ability to send messages
# or alerts to multiple messaging platforms.
# grade: stable
# confinement: classic
# publish: false
scoop:
bucket:
owner: kha7iq
name: scoop-bucket
homepage: https://pingme.lmno.pk
description: Deliver Go binaries as fast and easily as possible
license: MIT
dockers:
- image_templates:
- 'khaliq/pingme:{{ .Tag }}-amd64'
- 'ghcr.io/kha7iq/pingme:{{ .Tag }}-amd64'
dockerfile: Dockerfile
use_buildx: true
build_flag_templates:
- "--pull"
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.name={{.ProjectName}}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.version={{.Version}}"
- "--label=org.opencontainers.image.source={{.GitURL}}"
- "--platform=linux/amd64"
extra_files:
- scripts/entrypoint.sh
- image_templates:
- 'khaliq/pingme:{{ .Tag }}-arm64'
- 'ghcr.io/kha7iq/pingme:{{ .Tag }}-arm64'
dockerfile: Dockerfile
use_buildx: true
build_flag_templates:
- "--pull"
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.name={{.ProjectName}}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.version={{.Version}}"
- "--label=org.opencontainers.image.source={{.GitURL}}"
- "--platform=linux/arm64"
goarch: arm64
extra_files:
- scripts/entrypoint.sh
docker_manifests:
- name_template: 'khaliq/pingme:{{ .Tag }}'
image_templates:
- 'khaliq/pingme:{{ .Tag }}-amd64'
- 'khaliq/pingme:{{ .Tag }}-arm64'
- name_template: 'ghcr.io/kha7iq/pingme:{{ .Tag }}'
image_templates:
- 'ghcr.io/kha7iq/pingme:{{ .Tag }}-amd64'
- 'ghcr.io/kha7iq/pingme:{{ .Tag }}-arm64'
- name_template: 'khaliq/pingme:latest'
image_templates:
- 'khaliq/pingme:{{ .Tag }}-amd64'
- 'khaliq/pingme:{{ .Tag }}-arm64'
- name_template: 'ghcr.io/kha7iq/pingme:latest'
image_templates:
- 'ghcr.io/kha7iq/pingme:{{ .Tag }}-amd64'
- 'ghcr.io/kha7iq/:{{ .Tag }}-arm64'

@ -0,0 +1,6 @@
#!/usr/bin/env sh
[ "$PINGME_USE_SERVICE" ]
: ${PINGME_USE_SERVICE:=""}
pingme $PINGME_USE_SERVICE
Loading…
Cancel
Save