2020-03-25 08:13:36 +03:00
|
|
|
name: Release
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
tags:
|
|
|
|
- 'v*.*.*'
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
release:
|
|
|
|
name: Release
|
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
os: [ ubuntu-latest ]
|
2020-08-21 05:40:26 +03:00
|
|
|
go: [ '1.15' ]
|
2020-03-25 08:13:36 +03:00
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Install Go
|
2020-08-21 05:40:26 +03:00
|
|
|
uses: actions/setup-go@v2
|
2020-03-25 08:13:36 +03:00
|
|
|
with:
|
2020-08-21 05:40:26 +03:00
|
|
|
go-version: ${{ matrix.go }}
|
2020-03-25 08:13:36 +03:00
|
|
|
|
|
|
|
- name: Checkout code
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
|
|
|
|
# So GoReleaser can generate the changelog properly
|
|
|
|
- name: Unshallowify the repo clone
|
|
|
|
run: git fetch --prune --unshallow
|
|
|
|
|
2020-04-27 05:20:14 +03:00
|
|
|
# https://github.community/t5/GitHub-Actions/How-to-get-just-the-tag-name/m-p/32167/highlight/true#M1027
|
2020-03-25 08:13:36 +03:00
|
|
|
- name: Print Go version and environment
|
|
|
|
id: vars
|
|
|
|
run: |
|
|
|
|
printf "Using go at: $(which go)\n"
|
|
|
|
printf "Go version: $(go version)\n"
|
|
|
|
printf "\n\nGo environment:\n\n"
|
|
|
|
go env
|
|
|
|
printf "\n\nSystem environment:\n\n"
|
|
|
|
env
|
2020-04-27 05:20:14 +03:00
|
|
|
echo "::set-output name=version_tag::${GITHUB_REF/refs\/tags\//}"
|
|
|
|
echo "::set-output name=short_sha::$(git rev-parse --short HEAD)"
|
|
|
|
echo "::set-output name=go_cache::$(go env GOCACHE)"
|
|
|
|
|
2020-06-05 19:23:15 +03:00
|
|
|
# Parse semver
|
|
|
|
TAG=${GITHUB_REF/refs\/tags\//}
|
|
|
|
SEMVER_RE='[^0-9]*\([0-9]*\)[.]\([0-9]*\)[.]\([0-9]*\)\([0-9A-Za-z\.-]*\)'
|
|
|
|
TAG_MAJOR=`echo ${TAG#v} | sed -e "s#$SEMVER_RE#\1#"`
|
|
|
|
TAG_MINOR=`echo ${TAG#v} | sed -e "s#$SEMVER_RE#\2#"`
|
|
|
|
TAG_PATCH=`echo ${TAG#v} | sed -e "s#$SEMVER_RE#\3#"`
|
|
|
|
TAG_SPECIAL=`echo ${TAG#v} | sed -e "s#$SEMVER_RE#\4#"`
|
|
|
|
echo "::set-output name=tag_major::${TAG_MAJOR}"
|
|
|
|
echo "::set-output name=tag_minor::${TAG_MINOR}"
|
|
|
|
echo "::set-output name=tag_patch::${TAG_PATCH}"
|
|
|
|
echo "::set-output name=tag_special::${TAG_SPECIAL}"
|
|
|
|
|
2020-04-27 05:20:14 +03:00
|
|
|
- name: Cache the build cache
|
2020-08-21 05:40:26 +03:00
|
|
|
uses: actions/cache@v2
|
2020-04-27 05:20:14 +03:00
|
|
|
with:
|
|
|
|
path: ${{ steps.vars.outputs.go_cache }}
|
2020-08-21 05:40:26 +03:00
|
|
|
key: ${{ runner.os }}-go${{ matrix.go }}-release-${{ hashFiles('**/go.sum') }}
|
2020-04-27 05:20:14 +03:00
|
|
|
restore-keys: |
|
2020-08-21 05:40:26 +03:00
|
|
|
${{ runner.os }}-go${{ matrix.go }}-release
|
2020-03-25 08:13:36 +03:00
|
|
|
|
|
|
|
# GoReleaser will take care of publishing those artifacts into the release
|
|
|
|
- name: Run GoReleaser
|
2020-08-21 05:40:26 +03:00
|
|
|
uses: goreleaser/goreleaser-action@v2
|
2020-03-25 08:13:36 +03:00
|
|
|
with:
|
|
|
|
version: latest
|
|
|
|
args: release --rm-dist
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
2020-04-27 05:20:14 +03:00
|
|
|
TAG: ${{ steps.vars.outputs.version_tag }}
|
|
|
|
|
2020-06-05 19:23:15 +03:00
|
|
|
# Only publish on non-special tags (e.g. non-beta)
|
2020-04-27 05:20:14 +03:00
|
|
|
- name: Publish .deb to Gemfury
|
2020-06-26 00:58:44 +03:00
|
|
|
if: ${{ steps.vars.outputs.tag_special == '' }}
|
2020-04-27 05:20:14 +03:00
|
|
|
env:
|
|
|
|
GEMFURY_PUSH_TOKEN: ${{ secrets.GEMFURY_PUSH_TOKEN }}
|
|
|
|
run: |
|
|
|
|
for filename in dist/*.deb; do
|
|
|
|
curl -F package=@"$filename" https://${GEMFURY_PUSH_TOKEN}:@push.fury.io/caddy/
|
2020-05-06 23:42:55 +03:00
|
|
|
done
|
|
|
|
|