Skip to content

Merge pull request #162 from Leaseweb/feat/k8s_1_30 #94

Merge pull request #162 from Leaseweb/feat/k8s_1_30

Merge pull request #162 from Leaseweb/feat/k8s_1_30 #94

Workflow file for this run

name: Release
on:
push:
branches:
- master
tags:
- v*
env:
REGISTRY_NAME: ghcr.io/leaseweb
IMAGES: "cloudstack-csi-driver cloudstack-csi-sc-syncer"
jobs:
push:
name: Push images
runs-on: ubuntu-24.04
steps:
- name: Check out code
uses: actions/checkout@v4
- 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 container
- name: Log into registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{github.actor}}
password: ${{secrets.GITHUB_TOKEN}}
- name: Push master
if: github.ref == 'refs/heads/master'
run: |
for img in $IMAGES; do
docker tag ${img} ${REGISTRY_NAME}/${img}:master
docker push ${REGISTRY_NAME}/${img}:master
done
- name: Push tagged release
if: startsWith(github.ref, 'refs/tags/v')
run: |
# Strip prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,' | sed -e 's/^v//')
for img in $IMAGES; do
docker tag ${img} ${REGISTRY_NAME}/${img}:${VERSION}
docker push ${REGISTRY_NAME}/${img}:${VERSION}
done
- name: Upload cloudstack-csi-sc-syncer artifact
if: startsWith(github.ref, 'refs/tags/v')
uses: actions/upload-artifact@v4
with:
name: bin
path: bin/cloudstack-csi-sc-syncer
retention-days: 1
release:
name: Release
runs-on: ubuntu-24.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: Create manifest
run: |
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,' | sed -e 's/^v//')
echo "---" >> manifest.yaml
cat deploy/k8s/rbac.yaml >> manifest.yaml
echo "---" >> manifest.yaml
cat deploy/k8s/csidriver.yaml >> manifest.yaml
echo "---" >> manifest.yaml
sed -E "s|image: +cloudstack-csi-driver|image: ${REGISTRY_NAME}/cloudstack-csi-driver:${VERSION}|" deploy/k8s/controller-deployment.yaml >> manifest.yaml
echo "---" >> manifest.yaml
sed -E "s|image: +cloudstack-csi-driver|image: ${REGISTRY_NAME}/cloudstack-csi-driver:${VERSION}|" deploy/k8s/node-daemonset.yaml >> manifest.yaml
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
draft: false
prerelease: false
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: manifest.yaml
asset_name: manifest.yaml
asset_content_type: application/x-yaml
- name: Download cloudstack-csi-sc-syncer artifact
uses: actions/download-artifact@v4
with:
name: bin
path: bin
- run: ls -l
- name: Upload cloudstack-csi-sc-syncer asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: bin/cloudstack-csi-sc-syncer
asset_name: cloudstack-csi-sc-syncer
asset_content_type: application/x-executable