Created
September 24, 2020 15:09
-
-
Save ldelossa/9aff418cf93c175866b723bc79a25975 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: Release | |
on: | |
push: | |
tags: | |
- v4.* | |
jobs: | |
build-binaries: | |
name: Build Binaries | |
runs-on: 'ubuntu-latest' | |
container: docker.io/library/golang:1.14 | |
- name: Checkout | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Build clairctl | |
run: | |
GOOS=darwin GOARCH=amd64 -o clairctl-darwin-amd64 ./cmd/clairctl | |
GOOS=linux GOARCH=amd64 -o clairctl-linux-amd64 ./cmd/clairctl | |
GOOS=windows GOARCH=amd64 -o clairctl-windows-amd64 ./cmd/clairctl | |
GOOS=darwin GOARCH=386 -o clairctl-darwin-386 ./cmd/clairctl | |
GOOS=linux GOARCH=386 -o clairctl-linux-386 ./cmd/clairctl | |
GOOS=windows GOARCH=386 -o clairctl-windows-386 ./cmd/clairctl | |
build-archive-and-container: | |
name: Build Archive and Container | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Prepare Environment | |
run: | | |
: "${tag:=${GITHUB_REF#refs/tags/}}" | |
cat <<. | |
::set-env name=CLAIR_VERSION::${tag} | |
::set-env name=PREFIX::clair-${tag}/ | |
::set-env name=TAG::quay.io/projectquay/clair:${tag#v} | |
. | |
- name: Create Release Archive | |
run: | | |
go mod vendor | |
git archive --prefix "${PREFIX}" -o clair.tar "${GITHUB_REF}" | |
tar -rf clair.tar --transform "s,^,${PREFIX}," vendor | |
gzip clair.tar | |
- name: Build Release Container | |
run: | | |
build=$(mktemp -d) | |
trap "rm -rf '${build}'" EXIT | |
tar -xzf clair.tar.gz -C "${build}" --strip-components 1 | |
docker build --build-arg CLAIR_VERSION --tag "${TAG}" "${build}" | |
release: | |
name: Release | |
needs: | |
- build-binaries | |
- build-archive-and-container | |
runs-on: 'ubuntu-latest' | |
container: docker.io/library/golang:1.14 | |
steps: | |
- name: Setup | |
run: | | |
tag=`basename ${{ github.ref }}` | |
cat <<. | |
::set-env name=VERSION::${tag} | |
::set-env name=TAG::quay.io/projectquay/clair:${tag#v} | |
::set-env name=QUAY_USER::projectquay+clair_github | |
::add-mask::${{ secrets.QUAY_TOKEN }} | |
. | |
- name: ChangeLog | |
shell: bash | |
run: | | |
curl -o git-chglog -L https://github.com/git-chglog/git-chglog/releases/download/0.9.1/git-chglog_linux_amd64 | |
chmod u+x git-chglog | |
tag=`basename ${{ github.ref }}` | |
echo "creating change log for tag: $tag" | |
chglog="$(./git-chglog ${tag})" | |
chglog="${chglog//'%'/'%25'}" | |
chglog="${chglog//$'\n'/'%0A'}" | |
chglog="${chglog//$'\r'/'%0D'}" | |
cat <<. | |
::set-env name=CHANGELOG::${chglog} | |
. | |
- name: Create Release | |
uses: actions/create-release@latest | |
id: create_release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ github.ref }} | |
release_name: ${{ env.VERSION}} Release | |
body: | | |
${{ env.CHANGELOG }} | |
prerelease: ${{ contains(env.VERSION, 'alpha') || contains(env.VERSION, 'beta') || contains(env.VERSION, 'rc') }} | |
- name: Publish Release Archive | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./clair.tar.gz | |
asset_name: clair-${{ env.CLAIR_VERSION }}.tar.gz | |
asset_content_type: application/gzip | |
- name: Publish clairctl-darwin-amd64 | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./clairctl-darwin-amd64 | |
asset_name: clairctl-darwin-amd64 | |
asset_content_type: application/octet-stream | |
- name: Publish clairctl-linux-amd64 | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./clairctl-linux-amd64 | |
asset_name: clairctl-linux-amd64 | |
asset_content_type: application/octet-stream | |
- name: Publish clairctl-windows-amd64 | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./clairctl-windows-amd64 | |
asset_name: clairctl-windows-amd64 | |
asset_content_type: application/octet-stream | |
- name: Publish clairctl-darwin-386 | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./clairctl-darwin-386 | |
asset_name: clairctl-darwin-386 | |
asset_content_type: application/octet-stream | |
- name: Publish clairctl-linux-386 | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./clairctl-linux-386 | |
asset_name: clairctl-linux-386 | |
asset_content_type: application/octet-stream | |
- name: Publish clairctl-windows-386 | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./clairctl-windows-386 | |
asset_name: clairctl-windows-386 | |
asset_content_type: application/octet-stream | |
- name: Publish Release Container | |
run: | | |
docker login -u "${QUAY_USER}" -p '${{ secrets.QUAY_TOKEN }}' quay.io | |
docker push "${TAG}" | |
deploy-documentation: | |
name: Deploy Documentation | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Setup | |
uses: peaceiris/actions-mdbook@v1 | |
with: | |
mdbook-version: 'latest' | |
- name: Build | |
run: mdbook build --dest-dir "./book/${GITHUB_REF#refs/tags/}" | |
- name: Deploy | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
user_name: 'github-actions[bot]' | |
user_email: 'github-actions[bot]@users.noreply.github.com' | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: ./book | |
keep_files: true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment