diff --git a/.github/workflows/goreleaser.yml b/.github/workflows/goreleaser.yml index befa0ca..374594c 100644 --- a/.github/workflows/goreleaser.yml +++ b/.github/workflows/goreleaser.yml @@ -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 }} \ No newline at end of file + 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 \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..cc1a2dc --- /dev/null +++ b/Dockerfile @@ -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 \ No newline at end of file diff --git a/goreleaser.yml b/goreleaser.yml index 6a2c6a5..6f20a00 100644 --- a/goreleaser.yml +++ b/goreleaser.yml @@ -66,4 +66,73 @@ nfpms: - deb - rpm dependencies: - - git \ No newline at end of file + - 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' \ No newline at end of file diff --git a/scripts/entrypoint.sh b/scripts/entrypoint.sh new file mode 100755 index 0000000..8152830 --- /dev/null +++ b/scripts/entrypoint.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env sh + +[ "$PINGME_USE_SERVICE" ] +: ${PINGME_USE_SERVICE:=""} + +pingme $PINGME_USE_SERVICE \ No newline at end of file