Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: docker image
on:
push:
branches:
- '*'
- '!master'
release:
types: [published]

jobs:
build_push:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Prepare
id: prep
run: |
DOCKER_IMAGE=messagebird/gcppromd
VERSION=edge
if [[ '${{ github.event_name }}' == 'release' ]]; then
VERSION=${GITHUB_REF#refs/tags/}
fi
TAGS="${DOCKER_IMAGE}:${VERSION}"
if [ "${{ github.event_name }}" = "push" ]; then
TAGS="$TAGS,${DOCKER_IMAGE}:sha-${GITHUB_SHA::8}"
fi
echo ::set-output name=version::${VERSION}
echo ::set-output name=tags::${TAGS}
echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
if: ${{ github.event_name == 'release' }}
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
push: ${{ github.event_name == 'release' }}
tags: ${{ steps.prep.outputs.tags }}
labels: |
org.opencontainers.image.source=${{ github.event.repository.html_url }}
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
org.opencontainers.image.revision=${{ github.sha }}
36 changes: 27 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: release

on:
push:
tags: ['v*']
tags: ["v*.*.*"]

jobs:
get-tag:
Expand All @@ -14,27 +14,39 @@ jobs:
- id: vars
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}
build:
env:
BIN_NAME: ${{ needs.get-tag.outputs.tag }}.${{ matrix.platform.goos }}-${{ matrix.platform.goarch }}
needs: [get-tag]
runs-on: ubuntu-latest
strategy:
matrix:
platform:
- {goos: darwin, goarch: amd64}
- {goos: linux, goarch: amd64}
- {goos: windows, goarch: amd64}
- { goos: darwin, goarch: amd64 }
- { goos: linux, goarch: amd64 }
- { goos: windows, goarch: amd64 }
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup go
uses: actions/setup-go@v1
with:
go-version: ^1.0
- run: CGO_ENABLED=0 GOOS=${{ matrix.platform.goos }} GOARCH=${{ matrix.platform.goarch }} go build -ldflags "-s -w" -o gcppromd-${{ needs.get-tag.outputs.tag }}.${{ matrix.platform.goos }}-${{ matrix.platform.goarch }} ./cmd/gcppromd
- name: Set binary name
id: binary_name
run: |
echo "BIN_NAME=gcppromd-${{ needs.get-tag.outputs.tag }}.${{ matrix.platform.goos }}-${{ matrix.platform.goarch }}" >> $GITHUB_ENV
- run: >-
CGO_ENABLED=0 GOOS=${{ matrix.platform.goos }}
GOARCH=${{ matrix.platform.goarch }}
go build -ldflags "-s -w" -o ${{ env.BIN_NAME }} ./cmd/gcppromd &&
shasum -a 256 ${{ env.BIN_NAME }} > ${{ env.BIN_NAME }}.sha256
- name: Upload binary
uses: actions/upload-artifact@v2
with:
name: binary.${{ matrix.platform.goos }}-${{ matrix.platform.goarch }}
path: gcppromd-${{ needs.get-tag.outputs.tag }}.${{ matrix.platform.goos }}-${{ matrix.platform.goarch }}
name: binary.${{ env.BIN_NAME }}
path: |
${{ env.BIN_NAME }}
${{ env.BIN_NAME }}.sha256
if-no-files-found: error
release:
needs: [get-tag, build]
Expand All @@ -45,12 +57,18 @@ jobs:
- uses: actions/download-artifact@v2
with:
path: .
# git fetch --tags --force is required because GitHub checkout action doesn't seems to preserve the tag annotation.
- name: Retrive release message
run: |
echo 'RELEASE_MSG<<EOF' >> $GITHUB_ENV
git fetch --tags --force && git tag -l --format='%(contents)' ${{ needs.get-tag.outputs.tag }} >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
- name: Release
uses: softprops/action-gh-release@v1
with:
draft: true
body_path: CHANGELOGS/${{ needs.get-tag.outputs.tag }}.md
body: ${{ env.RELEASE_MSG }}
files: |
binary.*/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7 changes: 5 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: test
on: push

on:
push:
branches:
- '*'
- '!master'
jobs:
test:
runs-on: ubuntu-latest
Expand Down