Skip to content

Merge pull request #34 from Leaseweb/develop #88

Merge pull request #34 from Leaseweb/develop

Merge pull request #34 from Leaseweb/develop #88

Workflow file for this run

name: Release
on:
push:
branches:
- main
- develop
tags:
- v*
env:
REGISTRY: ghcr.io/leaseweb
IMAGE_NAME: capi-cloudstack-controller
TAG: build
jobs:
push:
name: Push images
runs-on: ubuntu-22.04
steps:
- name: Check out code
uses: actions/checkout@v4
with:
fetch-depth: 0
# This step is run when the branch is main and no tag is set
- name: Sets env vars for main
run: |
echo "TAG=latest" >> $GITHUB_ENV
if: github.ref == 'refs/heads/main' && !startsWith(github.ref, 'refs/tags/v')
# This step is run when the branch is develop
- name: Sets env vars for develop
run: |
echo "TAG=develop" >> $GITHUB_ENV
if: github.ref == 'refs/heads/develop'
# This step is run when there is a tag
- name: Sets env vars for tag
run: |
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,' | sed -e 's/^v//')
echo "TAG=${VERSION}" >> $GITHUB_ENV
if: startsWith(github.ref, 'refs/tags/v')
- name: Cache
uses: actions/cache@v4
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Build container images
run: make docker-build
- name: Log into registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{github.actor}}
password: ${{secrets.GITHUB_TOKEN}}
- name: Push
run: |
docker push ${REGISTRY}/${IMAGE_NAME}:${TAG}
release:
name: Release
runs-on: ubuntu-22.04
# Run only if previous job has succeeded
needs: [push]
# Create a release only for tags v*
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Build release manifests
run: make release-manifests
- name: Release
uses: softprops/action-gh-release@v2
with:
prerelease: false
draft: true
fail_on_unmatched_files: true
generate_release_notes: true
name: ${{ env.TAG }}
files: |
out/metadata.yaml
out/infrastructure-components.yaml