1010 - " **"
1111 schedule :
1212 - cron : " 0 3 * * *" # run every day at 3am UTC (nightly builds)
13- workflow_call :
13+ workflow_dispatch :
1414 inputs :
1515 is_production_release :
16+ description : ' Is this a production release?'
1617 required : false
1718 type : boolean
1819 default : false
1920 release_version :
21+ description : ' Release version (e.g., v2.0.3)'
2022 required : false
2123 type : string
2224 default : ' '
2325 operator_version :
26+ description : ' Operator release version (e.g., v1.0.0). Optional'
2427 required : false
2528 type : string
2629 default : ' '
2730 dry_run :
31+ description : ' If true, does a dry run of the production workflow'
2832 required : false
2933 type : boolean
3034 default : false
@@ -41,9 +45,68 @@ permissions:
4145 contents : read
4246
4347jobs :
48+ create-tag-and-release :
49+ runs-on : ubuntu-24.04
50+ if : github.event_name == 'workflow_dispatch' && inputs.release_version != '' && startsWith(github.ref, 'refs/heads/release-')
51+ permissions :
52+ contents : write
53+ steps :
54+ - name : Validate Release Branch and Version
55+ run : |
56+ echo "Validating release from: ${GITHUB_REF}"
57+
58+ INPUT_VERSION="${{ inputs.release_version }}"
59+ INPUT_OPERATOR_VERSION="${{ inputs.operator_version }}"
60+
61+ # Validate version format
62+ if [[ ! "${INPUT_VERSION}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
63+ echo "❌ Invalid version format: ${INPUT_VERSION}"
64+ echo "Expected format: v1.2.3"
65+ exit 1
66+ fi
67+
68+ # Validate version format if operator version is provided
69+ if [[ -n "${INPUT_OPERATOR_VERSION}" && ! "${INPUT_OPERATOR_VERSION}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
70+ echo "❌ Invalid operator version format: ${INPUT_OPERATOR_VERSION}"
71+ echo "Expected format: v1.2.3"
72+ exit 1
73+ fi
74+
75+ echo "✅ Valid release branch: ${GITHUB_REF}"
76+ echo "✅ Valid version format: ${INPUT_VERSION}"
77+ [[ -n "${INPUT_OPERATOR_VERSION}" ]] && echo "✅ Valid operator version format: ${INPUT_OPERATOR_VERSION}"
78+
79+ - name : Checkout Repository
80+ uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
81+ with :
82+ fetch-depth : 0
83+
84+ - name : Create Release Tag
85+ run : |
86+ VERSION="${{ inputs.release_version }}"
87+ git config user.name "NGF Release Bot"
88+ git config user.email "[email protected] " 89+
90+ if git rev-parse --verify "refs/tags/${VERSION}" >/dev/null 2>&1; then
91+ echo "Tag ${VERSION} already exists - skipping tag creation"
92+ else
93+ echo "Creating annotated tag ${VERSION}"
94+ git tag -a "${VERSION}" -m "Release ${VERSION}"
95+
96+ if [[ "${{ inputs.dry_run }}" == "true" ]]; then
97+ echo "DRY RUN: Would push tag ${VERSION} and operator tag ${{ inputs.operator_version || '' }}"
98+ git push --dry-run origin "${VERSION}"
99+ else
100+ git push origin "${VERSION}"
101+ echo "Created and pushed tag: ${VERSION}"
102+ fi
103+ fi
104+
44105 vars :
45106 name : Checks and variables
46107 runs-on : ubuntu-24.04
108+ needs : [create-tag-and-release]
109+ if : always() && (needs.create-tag-and-release.result == 'success' || needs.create-tag-and-release.result == 'skipped')
47110 outputs :
48111 go_path : ${{ steps.vars.outputs.go_path }}
49112 min_k8s_version : ${{ steps.vars.outputs.min_k8s_version }}
0 commit comments