Skip to content

Release

Release #101

Workflow file for this run

name: Release
on:
workflow_dispatch:
inputs:
release_candidate:
type: boolean
description: "Release Candidate"
required: false
default: false
env:
REGISTRY: ghcr.io
DOCKERFILE: ${{ github.workspace }}/goreleaser.dockerfile
jobs:
tests:
uses: ./.github/workflows/tests.yaml
permissions:
contents: read
pull-requests: 'read'
release:
needs: tests
name: Trigger release build
runs-on: large_runner
permissions:
contents: 'write'
id-token: 'write'
pull-requests: 'read'
repository-projects: 'write'
packages: 'write'
steps:
- name: Self Hosted Runner Post Job Cleanup Action
uses: TooMuch4U/actions-clean@9b358e33df99574ac0bdf2e92fa3db1ae1415563
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5
with:
go-version-file: '${{ github.workspace }}/go.mod'
- name: Cache go-build and mod
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684
with:
path: |
~/.cache/go-build/
~/go/pkg/mod/
key: go-${{ hashFiles('go.sum') }}
restore-keys: |
go-
- name: Set release version
run: |
if ${{ inputs.release_candidate }}; then
echo "RELEASE_VERSION=$(go run $GITHUB_WORKSPACE/pkg/version/generate/release_generate.go print-rc-version)" >> $GITHUB_ENV
else
echo "RELEASE_VERSION=$(go run $GITHUB_WORKSPACE/pkg/version/generate/release_generate.go print-version)" >> $GITHUB_ENV
fi
- name: Set release notes file
run: |
echo "RELEASE_NOTES_FILE=docs/release_notes/$(go run $GITHUB_WORKSPACE/pkg/version/generate/release_generate.go print-version).md" >> $GITHUB_ENV
- name: Validate release notes
run: |
if [[ ! -f ${{ env.RELEASE_NOTES_FILE }} ]]; then
>&2 echo "Must have release notes ${{ env.RELEASE_NOTES_FILE }}"
exit 6
fi
- name: Create and push branch
env:
RELEASE_BRANCH: release-${{ env.RELEASE_VERSION }}
run: |
if ! git checkout ${RELEASE_BRANCH} >/dev/null; then
echo "Creating ${RELEASE_BRANCH} from $(git branch --show-current)"
git checkout -b ${RELEASE_BRANCH}
git push origin "$(git branch --show-current)"
else
git checkout ${RELEASE_BRANCH}
git pull --ff-only origin ${RELEASE_BRANCH}
fi
- name: Setup git config
run: |
git config user.name "GitHub Actions Bot"
git config user.email "<41898282+github-actions[bot]@users.noreply.github.com>"
- name: Create and push tag
run: |
msg="Release ${{ env.RELEASE_VERSION }}"
git tag --annotate --message "${msg}" ${{ env.RELEASE_VERSION }}
git push origin ${{ env.RELEASE_VERSION }}
- name: Log in to the Container registry
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Install Helm
uses: azure/setup-helm@b9e51907a09c216f16ebe8536097933489208112
- name: Generate manifests
run: |
mkdir -p output
helm template ./deploy --namespace ocm-system --set "manager.image.tag=${{ env.RELEASE_VERSION }}" --include-crds > ./output/install.yaml
- name: Setup Syft
uses: anchore/sbom-action/download-syft@e11c554f704a0b820cbf8c51673f6945e0731532 # v0.20.0
- name: Setup Cosign
uses: sigstore/cosign-installer@3454372f43399081ed03b604cb2d021dabca52bb
- name: Run goreleaser
uses: goreleaser/goreleaser-action@9c156ee8a17a598857849441385a2041ef570552
with:
distribution: goreleaser
version: latest
args: release --clean --timeout 60m --config=./.goreleaser.yaml --release-notes=${{ env.RELEASE_NOTES_FILE }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GORELEASER_CURRENT_TAG: ${{ env.RELEASE_VERSION }}
- name: Build and release the helm charts
run: |
helm registry login ghcr.io -u open-component-model -p ${{ secrets.GITHUB_TOKEN }}
helm package --version ${{ env.RELEASE_VERSION }} --app-version ${{ env.RELEASE_VERSION }} ./deploy
helm push ${{ github.event.repository.name }}-${{ env.RELEASE_VERSION }}.tgz oci://ghcr.io/open-component-model/helm
- name: Push OCM Components
env:
GITHUBORG: ${{ github.repository_owner }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: make plain-push