2021-02-18 20:38:32 +00:00
|
|
|
name: Create Release & Upload Assets
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
# Sequence of patterns matched against refs/tags
|
|
|
|
tags:
|
|
|
|
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
|
|
|
|
|
|
|
|
jobs:
|
2021-02-18 22:28:17 +00:00
|
|
|
test:
|
2021-02-18 20:38:32 +00:00
|
|
|
name: Lint, Test, Build
|
2021-02-23 05:05:24 +00:00
|
|
|
runs-on: ubuntu-20.04
|
2021-04-13 22:53:49 +00:00
|
|
|
strategy:
|
|
|
|
matrix:
|
2022-03-21 23:22:26 +00:00
|
|
|
go: [ '1.17', '1.18' ]
|
2021-02-18 21:55:50 +00:00
|
|
|
outputs:
|
|
|
|
is_prerelease: ${{ steps.is_prerelease.outputs.IS_PRERELEASE }}
|
2021-02-18 20:38:32 +00:00
|
|
|
steps:
|
2021-02-18 21:55:50 +00:00
|
|
|
-
|
|
|
|
name: Checkout
|
2021-02-18 20:38:32 +00:00
|
|
|
uses: actions/checkout@v2
|
2021-02-18 21:55:50 +00:00
|
|
|
-
|
|
|
|
name: Setup Go
|
2021-02-18 20:38:32 +00:00
|
|
|
uses: actions/setup-go@v2
|
|
|
|
with:
|
2021-04-13 22:53:49 +00:00
|
|
|
go-version: ${{ matrix.go }}
|
2021-02-18 21:55:50 +00:00
|
|
|
-
|
|
|
|
name: Install Deps
|
2021-02-18 21:09:27 +00:00
|
|
|
id: install-deps
|
|
|
|
run: sudo apt-get -y install libpcsclite-dev
|
2021-04-13 22:31:33 +00:00
|
|
|
-
|
|
|
|
name: golangci-lint
|
|
|
|
uses: golangci/golangci-lint-action@v2
|
|
|
|
with:
|
|
|
|
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
|
2022-03-21 23:22:26 +00:00
|
|
|
version: 'v1.45.0'
|
2021-04-13 22:31:33 +00:00
|
|
|
|
|
|
|
# Optional: working directory, useful for monorepos
|
|
|
|
# working-directory: somedir
|
|
|
|
|
|
|
|
# Optional: golangci-lint command line arguments.
|
2021-04-13 22:42:54 +00:00
|
|
|
args: --timeout=30m
|
2021-04-13 22:31:33 +00:00
|
|
|
|
|
|
|
# Optional: show only new issues if it's a pull request. The default value is `false`.
|
|
|
|
# only-new-issues: true
|
|
|
|
|
|
|
|
# Optional: if set to true then the action will use pre-installed Go.
|
|
|
|
# skip-go-installation: true
|
|
|
|
|
|
|
|
# Optional: if set to true then the action don't cache or restore ~/go/pkg.
|
|
|
|
# skip-pkg-cache: true
|
|
|
|
|
|
|
|
# Optional: if set to true then the action don't cache or restore ~/.cache/go-build.
|
|
|
|
# skip-build-cache: true
|
2021-02-18 21:55:50 +00:00
|
|
|
-
|
2021-04-13 22:38:36 +00:00
|
|
|
name: Test, Build
|
2021-02-18 22:28:17 +00:00
|
|
|
id: lint_test_build
|
2021-04-13 22:31:33 +00:00
|
|
|
run: V=1 make ci
|
2021-02-18 20:38:32 +00:00
|
|
|
|
2021-02-23 05:05:24 +00:00
|
|
|
create_release:
|
|
|
|
name: Create Release
|
2021-02-18 22:28:17 +00:00
|
|
|
needs: test
|
2021-02-23 05:05:24 +00:00
|
|
|
runs-on: ubuntu-20.04
|
|
|
|
outputs:
|
2021-09-11 20:05:17 +00:00
|
|
|
debversion: ${{ steps.extract-tag.outputs.DEB_VERSION }}
|
2021-02-23 05:05:24 +00:00
|
|
|
is_prerelease: ${{ steps.is_prerelease.outputs.IS_PRERELEASE }}
|
|
|
|
steps:
|
2021-09-11 20:05:17 +00:00
|
|
|
-
|
|
|
|
name: Extract Tag Names
|
|
|
|
id: extract-tag
|
|
|
|
run: |
|
|
|
|
DEB_VERSION=$(echo ${GITHUB_REF#refs/tags/v} | sed 's/-/./')
|
|
|
|
echo "::set-output name=DEB_VERSION::${DEB_VERSION}"
|
2021-02-23 05:05:24 +00:00
|
|
|
-
|
|
|
|
name: Is Pre-release
|
|
|
|
id: is_prerelease
|
|
|
|
run: |
|
|
|
|
set +e
|
|
|
|
echo ${{ github.ref }} | grep "\-rc.*"
|
|
|
|
OUT=$?
|
|
|
|
if [ $OUT -eq 0 ]; then IS_PRERELEASE=true; else IS_PRERELEASE=false; fi
|
|
|
|
echo "::set-output name=IS_PRERELEASE::${IS_PRERELEASE}"
|
|
|
|
-
|
|
|
|
name: Create Release
|
|
|
|
id: create_release
|
|
|
|
uses: actions/create-release@v1
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
with:
|
|
|
|
tag_name: ${{ github.ref }}
|
|
|
|
release_name: Release ${{ github.ref }}
|
|
|
|
draft: false
|
|
|
|
prerelease: ${{ steps.is_prerelease.outputs.IS_PRERELEASE }}
|
|
|
|
|
|
|
|
goreleaser:
|
2021-02-23 05:25:40 +00:00
|
|
|
name: Upload Assets To Github w/ goreleaser
|
2021-02-23 05:05:24 +00:00
|
|
|
runs-on: ubuntu-20.04
|
|
|
|
needs: create_release
|
2021-02-18 20:38:32 +00:00
|
|
|
steps:
|
|
|
|
-
|
|
|
|
name: Checkout
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
|
|
|
-
|
|
|
|
name: Set up Go
|
|
|
|
uses: actions/setup-go@v2
|
|
|
|
with:
|
2022-03-21 23:22:26 +00:00
|
|
|
go-version: 1.18
|
2021-09-07 18:28:16 +00:00
|
|
|
-
|
|
|
|
name: APT Install
|
|
|
|
id: aptInstall
|
|
|
|
run: sudo apt-get -y install build-essential debhelper fakeroot
|
|
|
|
-
|
|
|
|
name: Build Debian package
|
|
|
|
id: make_debian
|
|
|
|
run: |
|
|
|
|
PATH=$PATH:/usr/local/go/bin:/home/admin/go/bin
|
|
|
|
make debian
|
|
|
|
# need to restore the git state otherwise goreleaser fails due to dirty state
|
|
|
|
git restore debian/changelog
|
|
|
|
git clean -fd
|
2021-08-30 23:52:40 +00:00
|
|
|
-
|
|
|
|
name: Install cosign
|
2021-09-07 18:28:16 +00:00
|
|
|
uses: sigstore/cosign-installer@v1.1.0
|
2021-08-30 23:52:40 +00:00
|
|
|
with:
|
|
|
|
cosign-release: 'v1.1.0'
|
|
|
|
-
|
|
|
|
name: Write cosign key to disk
|
|
|
|
id: write_key
|
|
|
|
run: echo "${{ secrets.COSIGN_KEY }}" > "/tmp/cosign.key"
|
2021-09-11 20:05:17 +00:00
|
|
|
-
|
|
|
|
name: Get Release Date
|
|
|
|
id: release_date
|
|
|
|
run: |
|
|
|
|
RELEASE_DATE=$(date +"%y-%m-%d")
|
|
|
|
echo "::set-output name=RELEASE_DATE::${RELEASE_DATE}"
|
2021-02-18 20:38:32 +00:00
|
|
|
-
|
|
|
|
name: Run GoReleaser
|
2021-08-30 23:52:40 +00:00
|
|
|
uses: goreleaser/goreleaser-action@5a54d7e660bda43b405e8463261b3d25631ffe86 # v2.7.0
|
2021-02-18 20:38:32 +00:00
|
|
|
with:
|
|
|
|
version: latest
|
|
|
|
args: release --rm-dist
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.PAT }}
|
2021-08-30 23:52:40 +00:00
|
|
|
COSIGN_PWD: ${{ secrets.COSIGN_PWD }}
|
2021-09-11 20:05:17 +00:00
|
|
|
DEB_VERSION: ${{ needs.create_release.outputs.debversion }}
|
|
|
|
RELEASE_DATE: ${{ steps.release_date.outputs.RELEASE_DATE }}
|
2021-02-18 20:38:32 +00:00
|
|
|
|
2021-02-18 22:28:17 +00:00
|
|
|
build_upload_docker:
|
|
|
|
name: Build & Upload Docker Images
|
2021-02-23 05:05:24 +00:00
|
|
|
runs-on: ubuntu-20.04
|
2021-02-18 22:44:05 +00:00
|
|
|
needs: test
|
2021-02-18 22:28:17 +00:00
|
|
|
steps:
|
2021-09-01 19:43:59 +00:00
|
|
|
-
|
|
|
|
name: Checkout
|
2021-02-18 22:28:17 +00:00
|
|
|
uses: actions/checkout@v2
|
2021-09-01 19:43:59 +00:00
|
|
|
-
|
|
|
|
name: Setup Go
|
2021-02-18 22:28:17 +00:00
|
|
|
uses: actions/setup-go@v2
|
|
|
|
with:
|
2022-03-21 23:22:26 +00:00
|
|
|
go-version: '1.18'
|
2021-09-01 19:43:59 +00:00
|
|
|
-
|
|
|
|
name: Install cosign
|
2021-09-07 18:28:16 +00:00
|
|
|
uses: sigstore/cosign-installer@v1.1.0
|
2021-09-01 19:43:59 +00:00
|
|
|
with:
|
|
|
|
cosign-release: 'v1.1.0'
|
|
|
|
-
|
|
|
|
name: Write cosign key to disk
|
|
|
|
id: write_key
|
|
|
|
run: echo "${{ secrets.COSIGN_KEY }}" > "/tmp/cosign.key"
|
|
|
|
-
|
|
|
|
name: Build
|
2021-02-18 22:28:17 +00:00
|
|
|
id: build
|
|
|
|
run: |
|
|
|
|
PATH=$PATH:/usr/local/go/bin:/home/admin/go/bin
|
|
|
|
make docker-artifacts
|
|
|
|
env:
|
|
|
|
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
|
|
|
|
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
|
2021-09-01 19:43:59 +00:00
|
|
|
COSIGN_PWD: ${{ secrets.COSIGN_PWD }}
|