-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
127 lines (112 loc) · 4.2 KB
/
action.yml
File metadata and controls
127 lines (112 loc) · 4.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
name: 'Releaseo'
description: 'Creates release PRs with version bumps for VERSION file and YAML files'
author: 'Stacklok'
branding:
icon: 'tag'
color: 'blue'
inputs:
releaseo_version:
description: 'Version of releaseo to use (e.g., v1.0.0). Must match a GitHub release.'
required: true
bump_type:
description: 'Version bump type (major, minor, patch)'
required: true
version_file:
description: 'Path to VERSION file'
required: false
default: 'VERSION'
helm_docs_args:
description: 'Arguments to pass to helm-docs. If provided, helm-docs will run with these args (e.g., --chart-search-root=./charts --template-files=README.md.gotmpl)'
required: false
default: ''
version_files:
description: |
YAML list of files with custom version paths to update.
Each entry should have: file (path), path (YAML node path), and optionally prefix.
Example:
- file: deploy/charts/myapp/Chart.yaml
path: version
- file: deploy/charts/myapp/Chart.yaml
path: appVersion
- file: deploy/charts/myapp/values.yaml
path: image.tag
prefix: "v"
required: false
default: ''
token:
description: 'GitHub token for creating PR'
required: true
base_branch:
description: 'Base branch for the PR'
required: false
default: 'main'
outputs:
version:
description: 'The new version number'
value: ${{ steps.releaseo.outputs.version }}
pr_number:
description: 'The created PR number'
value: ${{ steps.releaseo.outputs.pr_number }}
pr_url:
description: 'The created PR URL'
value: ${{ steps.releaseo.outputs.pr_url }}
runs:
using: 'composite'
steps:
- name: Validate version input
shell: bash
run: |
VERSION="${{ inputs.releaseo_version }}"
if [ -z "$VERSION" ]; then
echo "::error::The 'releaseo_version' input is required. Please specify the releaseo version (e.g., v1.0.0)"
exit 1
fi
if [[ ! "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "::error::Invalid version format '$VERSION'. Please use semantic versioning (e.g., v1.0.0)"
exit 1
fi
- name: Download releaseo binary
shell: bash
run: |
VERSION="${{ inputs.releaseo_version }}"
# Determine OS and architecture
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
ARCH=$(uname -m)
case "$ARCH" in
x86_64) ARCH="amd64" ;;
aarch64|arm64) ARCH="arm64" ;;
*) echo "::error::Unsupported architecture: $ARCH"; exit 1 ;;
esac
# Download the binary to runner temp directory (outside workspace)
ASSET_NAME="releaseo_${VERSION#v}_${OS}_${ARCH}.tar.gz"
ASSET_URL="https://github.com/stacklok/releaseo/releases/download/${VERSION}/${ASSET_NAME}"
echo "Downloading releaseo ${VERSION} for ${OS}/${ARCH}..."
if ! curl -sSL --fail -o "${{ runner.temp }}/releaseo.tar.gz" "$ASSET_URL"; then
echo "::error::Failed to download releaseo ${VERSION}. Ensure the release exists: https://github.com/stacklok/releaseo/releases/tag/${VERSION}"
exit 1
fi
# Extract only the binary (archive also contains LICENSE and README.md which we don't want)
tar xzf "${{ runner.temp }}/releaseo.tar.gz" -C "${{ runner.temp }}" releaseo
chmod +x "${{ runner.temp }}/releaseo"
rm "${{ runner.temp }}/releaseo.tar.gz"
echo "Successfully downloaded releaseo ${VERSION}"
- name: Run releaseo
id: releaseo
shell: bash
env:
GITHUB_TOKEN: ${{ inputs.token }}
VERSION_FILES_YAML: ${{ inputs.version_files }}
run: |
ARGS=(
--bump-type="${{ inputs.bump_type }}"
--version-file="${{ inputs.version_file }}"
--base-branch="${{ inputs.base_branch }}"
)
if [ -n "${{ inputs.helm_docs_args }}" ]; then
ARGS+=(--helm-docs-args="${{ inputs.helm_docs_args }}")
fi
if [ -n "$VERSION_FILES_YAML" ]; then
VERSION_FILES_JSON=$(echo "$VERSION_FILES_YAML" | yq -o=json -I=0 '.')
ARGS+=(--version-files="$VERSION_FILES_JSON")
fi
"${{ runner.temp }}/releaseo" "${ARGS[@]}"