Update CI workflow to publish releases to Cloudsmith (#26) #138
This file contains 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: Build | |
permissions: | |
contents: write | |
packages: write | |
on: | |
pull_request: | |
push: | |
branches: | |
- master | |
tags: | |
- "*" | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- | |
name: Checkout | |
uses: actions/checkout@v3 | |
- | |
name: Unshallow | |
run: git fetch --prune --unshallow | |
- | |
name: Set up Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version: 1.21 | |
env: | |
GOEXPERIMENT: boringcrypto | |
- | |
name: Run Tests | |
env: | |
GOEXPERIMENT: boringcrypto | |
run: go test ./... | |
- | |
name: Build and Publish (Dry Run) | |
uses: goreleaser/goreleaser-action@v3 | |
if: ${{ !startsWith(github.ref, 'refs/tags/') }} | |
with: | |
version: latest | |
args: release --skip-publish --clean --snapshot | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
GOEXPERIMENT: boringcrypto | |
- | |
name: Build and Publish | |
uses: goreleaser/goreleaser-action@v3 | |
if: ${{ startsWith(github.ref, 'refs/tags/') }} | |
with: | |
version: latest | |
args: release --clean | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
GOEXPERIMENT: boringcrypto | |
- | |
name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: | | |
ghcr.io/eventstore/es-gencert-cli | |
tags: | | |
type=ref,event=branch | |
type=ref,event=pr | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
type=semver,pattern={{major}} | |
type=sha | |
- | |
name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- | |
name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- | |
name: Login to GitHub Container Registry | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- | |
name: Push to GitHub Packages | |
uses: docker/build-push-action@v3 | |
with: | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ghcr.io/${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
platforms: linux/amd64,linux/arm64 | |
- | |
name: Login to Cloudsmith Registry | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v2 | |
with: | |
registry: docker.eventstore.com | |
username: ${{ secrets.CLOUDSMITH_CICD_USER }} | |
password: ${{ secrets.CLOUDSMITH_CICD_TOKEN }} | |
- | |
name: Push to Cloudsmith | |
uses: docker/build-push-action@v3 | |
with: | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: docker.eventstore.com/${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
platforms: linux/amd64,linux/arm64 | |
test-windows: | |
runs-on: windows-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version: 1.21 | |
- name: Run Tests | |
run: go test ./... |