Skip to content

Commit 0af4806

Browse files
Update release action (#197)
* clean up release scripts and santizie inputs * update path * fix valid check * fix conditionals and binary step * update README * remove set -euo pipefail * updates for go libs
1 parent 693aa51 commit 0af4806

File tree

7 files changed

+171
-448
lines changed

7 files changed

+171
-448
lines changed

.github/workflows/create-tag-release.yaml

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,29 @@ name: Create Tag and Release
1212
on:
1313
workflow_call:
1414
inputs:
15-
version:
16-
description: "Semantic version to release. Ex: major, minor, or patch"
15+
option:
16+
description: "Type of release. Ex: major, minor, patch, or version."
1717
type: string
1818
required: true
19-
images:
20-
description: "List of image names. Example: csi-powerstore,csi-isilon"
19+
version:
20+
description: "Specific semver version to release. Only used when 'version' is the selected option. Ex: v2.1.0."
2121
type: string
22-
required: true
22+
required: false
2323

2424
jobs:
25+
process-inputs:
26+
name: Process Inputs
27+
uses: dell/common-github-actions/.github/workflows/process-inputs.yaml@main
28+
with:
29+
option: ${{ inputs.option }}
30+
version: ${{ inputs.version }}
31+
secrets: inherit
32+
2533
build-and-scan:
2634
name: Build and Scan
35+
needs: [process-inputs]
36+
outputs:
37+
processedVersion: ${{ needs.process-inputs.outputs.processedVersion }}
2738
runs-on: ubuntu-latest
2839
steps:
2940
- name: Checkout the code
@@ -42,17 +53,17 @@ jobs:
4253
- name: Build binaries
4354
run: |
4455
echo "Building binaries to attach to the release if any..."
45-
if "${{ inputs.images == 'cert-csi' }}"; then
46-
make build
47-
mv cert-csi cert-csi-linux-amd64
48-
echo "BIN_NAME=cert-csi-linux-amd64" >> $GITHUB_ENV
56+
if [ "${GITHUB_REPOSITORY}" == "dell/cert-csi" ]; then
57+
make build
58+
mv cert-csi cert-csi-linux-amd64
59+
echo "BIN_NAME=cert-csi-linux-amd64" >> $GITHUB_ENV
4960
fi
50-
if "${{ contains(inputs.images, 'dell-csi-replicator') || contains(inputs.images, 'dell-replication-controller') }}"; then
51-
cd repctl
52-
make build
53-
mv repctl repctl-linux-amd64
54-
mv repctl-linux-amd64 ../
55-
echo "BIN_NAME=repctl-linux-amd64" >> $GITHUB_ENV
61+
if [ "${GITHUB_REPOSITORY}" == "dell/csm-replication" ]; then
62+
cd repctl
63+
make build
64+
mv repctl repctl-linux-amd64
65+
mv repctl-linux-amd64 ../
66+
echo "BIN_NAME=repctl-linux-amd64" >> $GITHUB_ENV
5667
fi
5768
5869
- name: Upload Binaries
@@ -66,8 +77,8 @@ jobs:
6677

6778
release-and-tag:
6879
name: Tag and Release
69-
needs: build-and-scan
80+
needs: [build-and-scan]
7081
uses: dell/common-github-actions/.github/workflows/release-creator.yaml@main
7182
with:
72-
version: ${{ inputs.version }}
83+
version: ${{ needs.build-and-scan.outputs.processedVersion }}
7384
secrets: inherit

.github/workflows/csm-release-driver-module.yaml

Lines changed: 0 additions & 129 deletions
This file was deleted.

.github/workflows/csm-release-libs.yaml

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,28 @@ name: Release Go Client Libraries
1313
on:
1414
workflow_call:
1515
inputs:
16-
version:
17-
description: 'Semantic version to release. Ex: major, minor, or patch'
16+
option:
17+
description: "Type of release. Ex: major, minor, patch, or version."
18+
type: string
1819
required: true
20+
version:
21+
description: "Specific semver version to release. Only used when 'version' is the selected option. Ex: v2.1.0."
1922
type: string
23+
required: false
2024
jobs:
25+
process-inputs:
26+
name: Process Inputs
27+
uses: dell/common-github-actions/.github/workflows/process-inputs.yaml@main
28+
with:
29+
option: ${{ inputs.option }}
30+
version: ${{ inputs.version }}
31+
secrets: inherit
32+
2133
build-and-scan:
2234
name: Build and Scan
35+
needs: [process-inputs]
36+
outputs:
37+
processedVersion: ${{ needs.process-inputs.outputs.processedVersion }}
2338
runs-on: ubuntu-latest
2439
steps:
2540
- name: Checkout the code
@@ -42,8 +57,8 @@ jobs:
4257

4358
release-and-tag:
4459
name: Tag and Release
45-
needs: build-and-scan
60+
needs: [build-and-scan]
4661
uses: dell/common-github-actions/.github/workflows/release-creator.yaml@main
4762
with:
48-
version: ${{ inputs.version }}
63+
version: ${{ needs.build-and-scan.outputs.processedVersion }}
4964
secrets: inherit
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Copyright (c) 2025 Dell Inc., or its subsidiaries. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
9+
name: Process Inputs for Release
10+
11+
# Invocable as a reusable workflow
12+
on:
13+
workflow_call:
14+
inputs:
15+
option:
16+
description: "Type of release. Ex: major, minor, patch, or version."
17+
type: string
18+
required: true
19+
version:
20+
description: "Specific semver version to release. Only used when 'version' is the selected option. Ex: v2.1.0."
21+
type: string
22+
required: false
23+
24+
outputs:
25+
processedVersion:
26+
description: "The type of release. Ex: major, minor, patch, or semver."
27+
value: ${{ jobs.process-inputs.outputs.processedVersion }}
28+
29+
jobs:
30+
process-inputs:
31+
name: Process Inputs
32+
runs-on: ubuntu-latest
33+
outputs:
34+
processedVersion: ${{ steps.set-version.outputs.versionEnv }}
35+
steps:
36+
- name: Process input
37+
id: set-version
38+
shell: bash
39+
run: |
40+
valid_options=("major" "minor" "patch" "version")
41+
if [[ ! "${valid_options[@]}" =~ "${{ inputs.option }}" ]]; then
42+
echo "Invalid option: ${{ inputs.option }}"
43+
exit 1
44+
fi
45+
46+
# When worker is triggered by "repository_dispatch" for auto release, if the input option
47+
# is not set to a default due to the action not going through "workflow_dispatch", the option
48+
# will be set to "minor" by default.
49+
if [[ "${{ inputs.option }}" == "" ]]; then
50+
echo "versionEnv=minor" >> "$GITHUB_OUTPUT"
51+
exit 0
52+
fi
53+
54+
if [[ "${{ inputs.option }}" == "version" && "${{ inputs.version }}" != "" ]]; then
55+
# if both version and option are provided, then version takes precedence i.e. for releasing a specific version, not incremental.
56+
57+
# remove prefix 'v'
58+
version="${{ inputs.version }}"
59+
clean_version="${version#v}"
60+
61+
# verify the version is in semver format
62+
if ! [[ "$clean_version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
63+
echo "Version "$clean_version" is not in semver format. Ex: v2.1.0"
64+
exit 1
65+
fi
66+
67+
echo "versionEnv=$clean_version" >> "$GITHUB_OUTPUT"
68+
exit 0
69+
fi
70+
71+
# This should take care of all other options aside from version.
72+
if [[ "${{ inputs.option }}" != "version" ]]; then
73+
# if only option is provided, then option takes precedence i.e. minor, major or patch release
74+
echo "versionEnv=${{ inputs.option }}" >> "$GITHUB_OUTPUT"
75+
exit 0
76+
fi
77+
78+
echo "Failed to process inputs"
79+
exit 1

0 commit comments

Comments
 (0)