Skip to content

Release

Release #114

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@08c6903cd8c0fde910a37f88322edcfb5dd907a8
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00
with:
go-version-file: '${{ github.workspace }}/go.mod'
- name: Cache go-build and mod
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830
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@5e57cd118135c172c3672efd75eb46360885c0ef
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Install Helm
uses: azure/setup-helm@1a275c3b69536ee54be43f2070a358922e12c8d4
- 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@8e94d75ddd33f69f691467e42275782e4bfefe84 # v0.20.9
- name: Setup Cosign
uses: sigstore/cosign-installer@faadad0cce49287aee09b3a48701e75088a2c6ad
- name: Run goreleaser
uses: goreleaser/goreleaser-action@e435ccd777264be153ace6237001ef4d979d3a7a
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