Skip to content

Commit

Permalink
feat: add goreleaser workflows (#266)
Browse files Browse the repository at this point in the history
* add goreleaser workflows

* add FULL_RELEASE var in goreleaser workflows

* add FULL_RELEASE var in goreleaser workflows

* minor typo
  • Loading branch information
dejanzele authored May 8, 2023
1 parent 7b47cf3 commit 2ca630c
Show file tree
Hide file tree
Showing 8 changed files with 271 additions and 102 deletions.
44 changes: 0 additions & 44 deletions .github/workflows/build-release-images.yml

This file was deleted.

30 changes: 18 additions & 12 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ on: [push, pull_request]

jobs:
go-lint:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3

- name: Setup Golang with cache
uses: magnetikonline/action-golang-cache@v4
with:
go-version: 1.19
cache: true
go-version: "1.20"

- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
Expand All @@ -20,13 +22,15 @@ jobs:
args: "-c ./.golangci.yml --timeout=10m --issues-exit-code=1 --max-issues-per-linter=0 --sort-results ./..."

go-unit-tests:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3

- name: Setup Golang with cache
uses: magnetikonline/action-golang-cache@v4
with:
go-version: 1.19
cache: true
go-version: "1.20"

- name: make test
run: make test

Expand All @@ -36,12 +40,14 @@ jobs:
files: ./operator.out # optional

go-integration-tests:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3

- name: Setup Golang with cache
uses: magnetikonline/action-golang-cache@v4
with:
go-version: 1.19
cache: true
go-version: "1.20"

- name: make test-integration
run: make test-integration
17 changes: 17 additions & 0 deletions .github/workflows/lint_pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: PR Lint

on:
pull_request_target:
types:
- opened
- edited
- synchronize

jobs:
main:
name: Validate PR title
runs-on: ubuntu-22.04
steps:
- uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
80 changes: 80 additions & 0 deletions .github/workflows/release-rc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: Release Armada Operator - RC

on:
push:
branches:
- main
- master

permissions:
contents: write

env:
DOCKER_REPO: "gresearch"

jobs:
release:
name: Release
runs-on: "ubuntu-22.04"

steps:
- name: "Checkout"
uses: "actions/checkout@v3"
with:
fetch-depth: 0

- name: Setup Golang with cache
uses: magnetikonline/action-golang-cache@v4
with:
go-version: ~1.20

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2

- name: "Docker login"
uses: "docker/login-action@v2"
with:
username: "${{ secrets.DOCKERHUB_USERNAME }}"
password: "${{ secrets.DOCKERHUB_TOKEN }}"

- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v0
with:
versionSpec: "6.x"
includePrerelease: true

- name: Determine Version
id: gitversion
uses: gittools/actions/gitversion/execute@v0

- name: Display GitVersion outputs (step output)
run: |
echo "Major: ${{ steps.gitversion.outputs.major }}"
echo "Minor: ${{ steps.gitversion.outputs.minor }}"
echo "Patch: ${{ steps.gitversion.outputs.patch }}"
echo "Sha: ${{ steps.gitversion.outputs.sha }}"
echo "ShortSha: ${{ steps.gitversion.outputs.shortSha }}"
- name: Set next RC version
id: "set_next_version"
run: echo "next_version=${{ steps.gitversion.outputs.majorMinorPatch }}-rc-${{ steps.gitversion.outputs.shortSha }}" >> $GITHUB_OUTPUT

- uses: rickstaa/action-create-tag@v1
id: "tag_create"
with:
tag: "v${{ steps.set_next_version.outputs.next_version }}"
tag_exists_error: true
message: "Armada Release Candidate for version v${{ steps.gitversion.outputs.majorMinorPatch }}"

- name: "Run GoReleaser"
uses: "goreleaser/goreleaser-action@v4"
with:
distribution: "goreleaser"
version: "v1.18.2"
args: "-f ./.goreleaser.yml release --clean --skip-publish --skip-sbom --skip-sign"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
DOCKER_BUILDX_BUILDER: "${{ steps.buildx.outputs.name }}"
DOCKER_BUILDX_CACHE_FROM: "type=gha"
DOCKER_BUILDX_CACHE_TO: "type=gha,mode=max"
73 changes: 73 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Release Armada Operator

on:
push:
tags:
- 'v*'

permissions:
contents: write
packages: write
issues: write

env:
DOCKER_REPO: "gresearch"

jobs:
release:
name: "Release"

runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Fetch Git tags
run: git fetch --force --tags

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.20"

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2

- name: "Docker login"
uses: "docker/login-action@v2"
with:
username: "${{ secrets.DOCKERHUB_USER }}"
password: "${{ secrets.DOCKERHUB_PASS }}"

- name: Set up Syft
run: curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh | sh -s -- -b /usr/local/bin

- name: Set GORELEASER_PREVIOUS_TAG # Workaround, GoReleaser uses 'git-describe' to determine a previous tag.
run: echo "GORELEASER_PREVIOUS_TAG=$(git -c 'versionsort.suffix=-rc' tag --list --sort=version:refname | grep -Eo '^v[0-9]{1,}.[0-9]{1,}.[0-9]{1,}$' | tail -n 2 | head -n 1)" >> $GITHUB_ENV

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4
with:
distribution: goreleaser
version: v1.18.2
args: "-f ./.goreleaser.yml release --clean"
env:
FULL_RELEASE: true
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
DOCKER_BUILDX_BUILDER: "${{ steps.buildx.outputs.name }}"
DOCKER_BUILDX_CACHE_FROM: "type=gha"
DOCKER_BUILDX_CACHE_TO: "type=gha,mode=max"

- name: Push README to Dockerhub
uses: christian-korneck/update-container-description-action@v1
env:
DOCKER_USER: ${{ secrets.DOCKERHUB_USER }}
DOCKER_PASS: ${{ secrets.DOCKERHUB_PASS }}
with:
destination_container_repo: ${{ env.DOCKER_REPO }}/armada-operator
provider: dockerhub
short_description: 'Armada Operator is the installer for Armada'
readme_file: 'README.md'
35 changes: 0 additions & 35 deletions .github/workflows/upload-docker-images.yml

This file was deleted.

Loading

0 comments on commit 2ca630c

Please sign in to comment.