99f9b2fb3e
Co-authored-by: Mariano Cano <mariano@smallstep.com>
117 lines
3.8 KiB
YAML
117 lines
3.8 KiB
YAML
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:
|
|
ci:
|
|
uses: smallstep/certificates/.github/workflows/ci.yml@master
|
|
secrets: inherit
|
|
|
|
create_release:
|
|
name: Create Release
|
|
needs: ci
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
DOCKER_IMAGE: smallstep/step-ca
|
|
outputs:
|
|
version: ${{ steps.extract-tag.outputs.VERSION }}
|
|
is_prerelease: ${{ steps.is_prerelease.outputs.IS_PRERELEASE }}
|
|
docker_tags: ${{ env.DOCKER_TAGS }}
|
|
docker_tags_hsm: ${{ env.DOCKER_TAGS_HSM }}
|
|
steps:
|
|
- 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 "IS_PRERELEASE=${IS_PRERELEASE}" >> ${GITHUB_OUTPUT}
|
|
- name: Extract Tag Names
|
|
id: extract-tag
|
|
run: |
|
|
VERSION=${GITHUB_REF#refs/tags/v}
|
|
echo "VERSION=${VERSION}" >> ${GITHUB_OUTPUT}
|
|
echo "DOCKER_TAGS=${{ env.DOCKER_IMAGE }}:${VERSION}" >> ${GITHUB_ENV}
|
|
echo "DOCKER_TAGS_HSM=${{ env.DOCKER_IMAGE }}:${VERSION}-hsm" >> ${GITHUB_ENV}
|
|
- name: Add Latest Tag
|
|
if: steps.is_prerelease.outputs.IS_PRERELEASE == 'false'
|
|
run: |
|
|
echo "DOCKER_TAGS=${{ env.DOCKER_TAGS }},${{ env.DOCKER_IMAGE }}:latest" >> ${GITHUB_ENV}
|
|
echo "DOCKER_TAGS_HSM=${{ env.DOCKER_TAGS_HSM }},${{ env.DOCKER_IMAGE }}:hsm" >> ${GITHUB_ENV}
|
|
- 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:
|
|
name: Upload Assets To Github w/ goreleaser
|
|
runs-on: ubuntu-latest
|
|
needs: create_release
|
|
permissions:
|
|
id-token: write
|
|
contents: write
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v3
|
|
with:
|
|
go-version: 1.19
|
|
check-latest: true
|
|
- name: Install cosign
|
|
uses: sigstore/cosign-installer@v2
|
|
with:
|
|
cosign-release: 'v1.13.1'
|
|
- name: Get Release Date
|
|
id: release_date
|
|
run: |
|
|
RELEASE_DATE=$(date +"%y-%m-%d")
|
|
echo "RELEASE_DATE=${RELEASE_DATE}" >> ${GITHUB_ENV}
|
|
- name: Run GoReleaser
|
|
uses: goreleaser/goreleaser-action@v3
|
|
with:
|
|
version: 'latest'
|
|
args: release --clean
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GORELEASER_PAT }}
|
|
RELEASE_DATE: ${{ env.RELEASE_DATE }}
|
|
COSIGN_EXPERIMENTAL: 1
|
|
|
|
build_upload_docker:
|
|
name: Build & Upload Docker Images
|
|
needs: create_release
|
|
permissions:
|
|
id-token: write
|
|
contents: write
|
|
uses: smallstep/workflows/.github/workflows/docker-buildx-push.yml@main
|
|
with:
|
|
platforms: linux/amd64,linux/386,linux/arm,linux/arm64
|
|
tags: ${{ needs.create_release.outputs.docker_tags }}
|
|
docker_image: smallstep/step-ca
|
|
docker_file: docker/Dockerfile
|
|
secrets: inherit
|
|
|
|
build_upload_docker_hsm:
|
|
name: Build & Upload HSM Enabled Docker Images
|
|
needs: create_release
|
|
permissions:
|
|
id-token: write
|
|
contents: write
|
|
uses: smallstep/workflows/.github/workflows/docker-buildx-push.yml@main
|
|
with:
|
|
platforms: linux/amd64,linux/386,linux/arm,linux/arm64
|
|
tags: ${{ needs.create_release.outputs.docker_tags_hsm }}
|
|
docker_image: smallstep/step-ca
|
|
docker_file: docker/Dockerfile.hsm
|
|
secrets: inherit
|