Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
67 changes: 39 additions & 28 deletions .github/workflows/main-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,34 +28,45 @@ jobs:
steps:
- name: Detect release type from ref
id: detect
shell: python3 {0}
run: |
ref_name="${{ inputs.ref_name }}"
echo "Analyzing ref: $ref_name"
import re
import os

ref_name = "${{ inputs.ref_name }}"
deployment_regex = r"${{ vars.TAG_REGEX_FOR_DEPLOYMENT }}"
prerelease_regex = r"${{ vars.TAG_REGEX_FOR_PRERELEASE }}"
dry_run_input = "${{ inputs.dry_run }}"

print(f"Analyzing ref: {ref_name}")

# Check if it's a standard semantic version tag (e.g., v1.2.3 or 1.2.3)
if [[ "$ref_name" =~ ${{ vars.TAG_REGEX_FOR_DEPLOYMENT }} ]]; then
echo "Standard release detected"
echo "is_dry_run=false" >> $GITHUB_OUTPUT
echo "is_prerelease=false" >> $GITHUB_OUTPUT
if re.match(deployment_regex, ref_name):
print("Standard release detected")
is_dry_run = "false"
is_prerelease = "false"

# Check if it's a pre-release tag (e.g., v1.2.3-RC1, 1.2.3-alpha1)
elif [[ "$ref_name" =~ ${{ vars.TAG_REGEX_FOR_PRERELEASE }} ]]; then
echo "Pre-release detected"
echo "is_dry_run=false" >> $GITHUB_OUTPUT
echo "is_prerelease=true" >> $GITHUB_OUTPUT
elif re.match(prerelease_regex, ref_name):
print("Pre-release detected")
is_dry_run = "false"
is_prerelease = "true"

# Everything else is a dry run (PRs, branches, etc.)
else
echo "Dry run detected"
echo "is_dry_run=true" >> $GITHUB_OUTPUT
echo "is_prerelease=false" >> $GITHUB_OUTPUT
fi
else:
print("Dry run detected")
is_dry_run = "true"
is_prerelease = "false"

# Override with explicit dry_run input if provided
if [[ "${{ inputs.dry_run }}" == "true" ]]; then
echo "Explicit dry_run input enabled - forcing dry run mode"
echo "is_dry_run=true" >> $GITHUB_OUTPUT
fi
if dry_run_input == "true":
print("Explicit dry_run input enabled - forcing dry run mode")
is_dry_run = "true"

# Write outputs
with open(os.environ['GITHUB_OUTPUT'], 'a') as f:
f.write(f"is_dry_run={is_dry_run}\n")
f.write(f"is_prerelease={is_prerelease}\n")

load-config:
name: Load and Validate Configuration
Expand Down Expand Up @@ -97,12 +108,13 @@ jobs:

- name: Generate build matrix
id: generate-matrix
shell: python3 {0}
run: |
# Parse configuration and generate build matrix
matrix=$(echo '${{ steps.load.outputs.config }}' | python3 -c "
import sys, yaml, json
config = yaml.safe_load(sys.stdin)
import yaml, json, os

config_yaml = '''${{ steps.load.outputs.config }}'''
config = yaml.safe_load(config_yaml)

matrix = {'include': []}
for build in config.get('builds', []):
if build.get('enabled', True):
Expand All @@ -112,10 +124,9 @@ jobs:
'config': json.dumps(build.get('config', {}))
}
matrix['include'].append(matrix_item)

print(json.dumps(matrix))
")
echo "matrix=$matrix" >> $GITHUB_OUTPUT

with open(os.environ['GITHUB_OUTPUT'], 'a') as f:
f.write(f"matrix={json.dumps(matrix)}\n")

- name: Parse release configuration
id: parse-release
Expand Down
4 changes: 1 addition & 3 deletions cd-actions/conda/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@ runs:
steps:
- name: Parse build configuration
id: config
shell: bash -el {0}
shell: python3 {0}
run: |
python3 <<'PY'
import json
import os
import sys
Expand Down Expand Up @@ -93,7 +92,6 @@ runs:
print(f"Artifact pattern: {artifact_pattern}")
print(f"Conda build args: {conda_build_args}")
print(f"Nexus URL: {nexus_url}")
PY

- name: Validate configuration files
id: validate
Expand Down
4 changes: 1 addition & 3 deletions cd-actions/python-pypi/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@ runs:
steps:
- name: Parse build configuration
id: config
shell: bash
shell: python3 {0}
run: |
python3 <<'PY'
import json
import os
import sys
Expand Down Expand Up @@ -73,7 +72,6 @@ runs:
print(f"Test PyPI: {str(testpypi).lower()}")
if env_vars:
print(f"Env vars: {list(env_vars.keys())}")
PY

- name: Set environment variables from config
if: steps.config.outputs.env_vars != ''
Expand Down
4 changes: 1 addition & 3 deletions cd-actions/release/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ runs:
steps:
- name: Parse release configuration
id: config
shell: bash
shell: python3 {0}
run: |
python3 <<'PY'
import yaml
import os

Expand Down Expand Up @@ -49,7 +48,6 @@ runs:
print(f"Prerelease: {prerelease}")
print(f"Draft: {draft}")
print(f"Make latest: {make_latest}")
PY

- name: Download all artifacts
uses: actions/download-artifact@v4
Expand Down