Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Github workflow for trigerring the csm release #103

Merged
merged 6 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
152 changes: 152 additions & 0 deletions .github/workflows/auto-release-csm-driver-module.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
# Copyright (c) 2024 Dell Inc., or its subsidiaries. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0

# This workflow is used to release CSI Drivers and modules.
name: Auto Release CSM Drivers and Modules
meggm marked this conversation as resolved.
Show resolved Hide resolved

on:
workflow_call:
workflow_dispatch:

jobs:
build-and-scan:
name: Build, Scan and Release
runs-on: ubuntu-latest
outputs:
new_version: ${{ steps.calculate_version.outputs.new_version }}
image_name: ${{ steps.extract_image.outputs.image_name }}
steps:
- name: Checkout the code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.23"

- name: Install dependencies
run: go mod tidy

- name: Build
run: go build -v ./...

- name: Run malware scan
uses: dell/common-github-actions/malware-scanner@main
with:
directories: .
options: -ri

- name: Run gosec
uses: dell/common-github-actions/gosec-runner@main
with:
directories: "./..."

- name: Get Latest Release Version
id: get_release
run: |
REPO="${{ github.repository }}"
echo "Fetching latest release for $REPO"
RELEASE_VERSION=$(curl -s "https://api.github.com/repos/$REPO/releases/latest" | jq -r '.tag_name' | sed 's/^v//')
if [[ "$RELEASE_VERSION" == "null" ]]; then
echo "No release found for $REPO"
RELEASE_VERSION="0.0.0"
fi
echo "Latest release version: $RELEASE_VERSION"
echo "::set-output name=release_version::$RELEASE_VERSION"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Calculate Next Minor Version
id: calculate_version
run: |
RELEASE_VERSION="${{ steps.get_release.outputs.release_version }}"
VERSION="$RELEASE_VERSION"
IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION"
NEXT_MINOR=$((MINOR + 1))
NEW_VERSION="$MAJOR.$NEXT_MINOR.0"
echo "Next version: $NEW_VERSION"
echo "::set-output name=new_version::$NEW_VERSION"

- name: Extract Image Name
id: extract_image
run: |
REPO="${{ github.repository }}"
IMAGE_NAME=$(echo "$REPO" | awk -F'/' '{print $2}')
echo "Image name: $IMAGE_NAME"
echo "::set-output name=image_name::$IMAGE_NAME"


push-images:
name: Pull, Tag and Push Images
needs: build-and-scan
runs-on: ubuntu-latest
steps:
- name: Log in to Quay.io
run: echo "${{ secrets.QUAY_PASSWORD }}" | docker login quay.io -u "${{ secrets.QUAY_USERNAME }}" --password-stdin

- name: Log in to Docker Hub
run: echo "${{ secrets.DOCKERHUB_PASSWORD }}" | docker login docker.io -u "${{ secrets.DOCKERHUB_USERNAME }}" --password-stdin

- name: Pull nightly image from Quay.io
#run: docker pull quay.io/dell/container-storage-modules/${{ steps.extract_image.outputs.image_name }}:nightly
run: echo "dummy pull"

- name: Retag image for Quay.io
#run: |
# docker tag quay.io/dell/container-storage-modules/${{ steps.extract_image.outputs.image_name }}:nightly quay.io/dell/container-storage-modules/${{ steps.extract_image.outputs.image_name }}:v${{ steps.calculate_version.outputs.new_version }}
# docker tag quay.io/dell/container-storage-modules/${{ steps.extract_image.outputs.image_name }}:nightly quay.io/dell/container-storage-modules/${{ steps.extract_image.outputs.image_name }}:latest
run: echo "dummy retag for Quay.io"
meggm marked this conversation as resolved.
Show resolved Hide resolved

- name: Retag image for Docker Hub
#run: |
# docker tag quay.io/dell/container-storage-modules/${{ steps.extract_image.outputs.image_name }}:nightly dellemc/${{ steps.extract_image.outputs.image_name }}:v${{ steps.calculate_version.outputs.new_version }}
# docker tag quay.io/dell/container-storage-modules/${{ steps.extract_image.outputs.image_name }}:nightly dellemc/${{ steps.extract_image.outputs.image_name }}:latest
run: echo "dummy retag for Docker Hub"

- name: Push ${{ steps.calculate_version.outputs.new_version }} and latest tag to Quay.io
run: echo "Dummy push"

- name: Push ${{ steps.calculate_version.outputs.new_version }} and latest tag to Docker Hub
run: echo "Dummy push"

create-release:
name: Create Release
needs:
- build-and-scan
- push-images
runs-on: ubuntu-latest
steps:
- name: Checkout the code
uses: actions/checkout@v4

- name: Create new tag
run: |
git config --global user.name 'github-actions'
git config --global user.email 'github-actions@github.com'
git tag v${{ needs.build-and-scan.outputs.new_version }}
git push origin v${{ needs.build-and-scan.outputs.new_version }}

- name: Create Release
id: release_notes
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ needs.build-and-scan.outputs.new_version }}
name: Release v${{ needs.build-and-scan.outputs.new_version }}
draft: true
prerelease: false
generate_release_notes: true
make_latest: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Create release branch
run: |
git config --global user.name 'github-actions'
git config --global user.email 'github-actions@github.com'
git checkout -b release/v${{ needs.build-and-scan.outputs.new_version }}
git push origin release/v${{ needs.build-and-scan.outputs.new_version }}
46 changes: 46 additions & 0 deletions .github/workflows/trigger-auto-csm-release-workflow.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Copyright (c) 2024 Dell Inc., or its subsidiaries. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0

# Trigger workflow for auto release of CSM projects
name: Trigger Auto Release Workflow
meggm marked this conversation as resolved.
Show resolved Hide resolved

on:
workflow_dispatch:

jobs:
trigger:
name: Trigger Auto Release
meggm marked this conversation as resolved.
Show resolved Hide resolved
runs-on: ubuntu-latest

strategy:
matrix:
repo:
[
"dell/csi-metadata-retriever",
#"dell/csi-powerflex",
"dell/csi-powermax",
#"dell/csi-powerscale",
"dell/csi-powerstore",
"dell/csi-unity",
"dell/csm-metrics-powermax",
"dell/csm-metrics-powerscale",
"dell/csm-metrics-powerstore",
"dell/csm-metrics-unity",
"dell/csm-operator",
"dell/csm-replication",
meggm marked this conversation as resolved.
Show resolved Hide resolved
]

steps:
- name: Trigger Auto Release
meggm marked this conversation as resolved.
Show resolved Hide resolved
uses: peter-evans/repository-dispatch@v3
with:
# For token information, see: https://github.com/peter-evans/repository-dispatch/tree/main?tab=readme-ov-file#token
token: ${{ secrets.CSMBOT_PAT }}
repository: ${{ matrix.repo }}
event-type: auto-release-workflow
client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}"}'
meggm marked this conversation as resolved.
Show resolved Hide resolved
Loading