|
| 1 | +name: Pipeline |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - "**" # Matches all branches |
| 7 | + pull_request: |
| 8 | + branches: |
| 9 | + - "**" # Matches all branches |
| 10 | + |
| 11 | + workflow_dispatch: |
| 12 | + inputs: |
| 13 | + force_build: |
| 14 | + description: "Forces a build even if no changes are detected" |
| 15 | + required: true |
| 16 | + default: "false" |
| 17 | + force_release: |
| 18 | + description: "Forces a release even if no changes are detected" |
| 19 | + required: true |
| 20 | + default: "false" |
| 21 | + |
| 22 | +concurrency: |
| 23 | + group: pipeline-${{ github.ref_name }} |
| 24 | + cancel-in-progress: true |
| 25 | + |
| 26 | +env: |
| 27 | + helm_chart_repository: "ghcr.io/emberstack/helm-charts" |
| 28 | + helm_chart_repository_protocol: "oci://" |
| 29 | + |
| 30 | +jobs: |
| 31 | + discovery: |
| 32 | + runs-on: ubuntu-latest |
| 33 | + permissions: |
| 34 | + contents: read |
| 35 | + pull-requests: read |
| 36 | + outputs: |
| 37 | + pathsFilter_src: ${{ steps.pathsFilter.outputs.src }} |
| 38 | + gitVersion_SemVer: ${{ steps.gitversion.outputs.GitVersion_SemVer }} |
| 39 | + gitVersion_AssemblySemFileVer: ${{ steps.gitversion.outputs.GitVersion_AssemblySemFileVer }} |
| 40 | + build: ${{ steps.evaluate_build.outputs.result }} |
| 41 | + build_configuration: ${{ steps.evaluate_build_configuration.outputs.result }} |
| 42 | + release: ${{ steps.evaluate_release.outputs.result }} |
| 43 | + steps: |
| 44 | + - name: checkout |
| 45 | + uses: actions/checkout@v4 |
| 46 | + with: |
| 47 | + fetch-depth: 0 |
| 48 | + |
| 49 | + - name: tools - dotnet - install |
| 50 | + uses: actions/setup-dotnet@v4 |
| 51 | + with: |
| 52 | + dotnet-version: "9.x" |
| 53 | + |
| 54 | + - name: tools - gitversion - install |
| 55 | + uses: gittools/actions/gitversion/[email protected] |
| 56 | + with: |
| 57 | + versionSpec: "5.x" |
| 58 | + preferLatestVersion: true |
| 59 | + |
| 60 | + - name: gitversion - execute |
| 61 | + id: gitversion |
| 62 | + uses: gittools/actions/gitversion/[email protected] |
| 63 | + with: |
| 64 | + useConfigFile: true |
| 65 | + configFilePath: GitVersion.yaml |
| 66 | + |
| 67 | + - name: tools - detect changes |
| 68 | + id: pathsFilter |
| 69 | + uses: dorny/paths-filter@v3 |
| 70 | + with: |
| 71 | + base: ${{ github.ref }} |
| 72 | + filters: | |
| 73 | + src: |
| 74 | + - '*.sln' |
| 75 | + - '*.slnx' |
| 76 | + - '*.props' |
| 77 | + - 'src/**' |
| 78 | + build: |
| 79 | + - '*.sln' |
| 80 | + - '*.slnx' |
| 81 | + - '*.props' |
| 82 | + - 'src/**' |
| 83 | + - 'tests/**' |
| 84 | + - 'playground/**' |
| 85 | +
|
| 86 | + - name: evaluate - build |
| 87 | + id: evaluate_build |
| 88 | + run: | |
| 89 | + if [ "${{ steps.pathsFilter.outputs.build }}" = "true" ] || \ |
| 90 | + [ "${{ github.event.inputs.force_build }}" = "true" ] || \ |
| 91 | + [ "${{ github.event.inputs.force_release }}" = "true" ]; then |
| 92 | + result=true |
| 93 | + else |
| 94 | + result=false |
| 95 | + fi |
| 96 | + echo "result=$result" >> $GITHUB_OUTPUT |
| 97 | +
|
| 98 | + - name: evaluate - build_configuration |
| 99 | + id: evaluate_build_configuration |
| 100 | + run: | |
| 101 | + if [ "${{ github.ref }}" = "refs/heads/main" ]; then |
| 102 | + result=Release |
| 103 | + else |
| 104 | + result=Debug |
| 105 | + fi |
| 106 | + echo "result=$result" >> $GITHUB_OUTPUT |
| 107 | +
|
| 108 | + - name: evaluate - release |
| 109 | + id: evaluate_release |
| 110 | + run: | |
| 111 | + if [ "${{ github.ref }}" = "refs/heads/main" ] || \ |
| 112 | + [ "${{ github.event.inputs.force_release }}" = "true" ]; then |
| 113 | + result=true |
| 114 | + else |
| 115 | + result=false |
| 116 | + fi |
| 117 | + echo "result=$result" >> $GITHUB_OUTPUT |
| 118 | +
|
| 119 | + build: |
| 120 | + name: build |
| 121 | + if: ${{ needs.discovery.outputs.build == 'true' }} |
| 122 | + needs: [discovery] |
| 123 | + runs-on: ubuntu-latest |
| 124 | + env: |
| 125 | + build: ${{ needs.discovery.outputs.build }} |
| 126 | + build_configuration: ${{ needs.discovery.outputs.build_configuration }} |
| 127 | + gitVersion_SemVer: ${{ needs.discovery.outputs.gitVersion_SemVer }} |
| 128 | + gitVersion_AssemblySemFileVer: ${{ needs.discovery.outputs.gitVersion_AssemblySemFileVer }} |
| 129 | + steps: |
| 130 | + - name: checkout |
| 131 | + uses: actions/checkout@v4 |
| 132 | + |
| 133 | + - name: artifacts - prepare directories |
| 134 | + run: | |
| 135 | + mkdir -p .artifacts/helm |
| 136 | + mkdir -p .artifacts/helm/repository |
| 137 | + mkdir -p .artifacts/kubectl |
| 138 | +
|
| 139 | + - name: tools - helm - install |
| 140 | + uses: azure/setup-helm@v4 |
| 141 | + |
| 142 | + - name: helm - package |
| 143 | + run: | |
| 144 | + for dir in src/charts/*; do |
| 145 | + [ -d "$dir" ] || continue |
| 146 | + helm_chart=$(basename "$dir") |
| 147 | + dest_dir=".artifacts/helm" |
| 148 | + mkdir -p "$dest_dir" |
| 149 | + helm package "$dir" --destination "$dest_dir" --version ${{ env.gitVersion_SemVer }} --app-version ${{ env.gitVersion_SemVer }} |
| 150 | + echo "Packaged $helm_chart to $dest_dir" |
| 151 | + done |
| 152 | +
|
| 153 | + - name: artifacts - helm - upload |
| 154 | + uses: actions/upload-artifact@v4 |
| 155 | + with: |
| 156 | + name: artifacts-helm-${{env.gitVersion_SemVer}} |
| 157 | + path: .artifacts/helm |
| 158 | + |
| 159 | + release: |
| 160 | + name: release |
| 161 | + if: ${{ needs.discovery.outputs.release == 'true' }} |
| 162 | + needs: [discovery, build] |
| 163 | + runs-on: ubuntu-latest |
| 164 | + env: |
| 165 | + gitVersion_SemVer: ${{ needs.discovery.outputs.gitVersion_SemVer }} |
| 166 | + gitVersion_AssemblySemFileVer: ${{ needs.discovery.outputs.gitVersion_AssemblySemFileVer }} |
| 167 | + steps: |
| 168 | + |
| 169 | + - name: artifacts - helm - download |
| 170 | + uses: actions/download-artifact@v4 |
| 171 | + with: |
| 172 | + name: artifacts-helm-${{env.gitVersion_SemVer}} |
| 173 | + path: .artifacts/helm |
| 174 | + |
| 175 | + - name: tools - helm - install |
| 176 | + uses: azure/setup-helm@v4 |
| 177 | + |
| 178 | + - name: tools - helm - login - ghcr.io |
| 179 | + run: echo "${{ secrets.ES_GITHUB_PAT }}" | helm registry login ghcr.io -u ${{ github.actor }} --password-stdin |
| 180 | + |
| 181 | + - name: tools - oras - install |
| 182 | + uses: oras-project/setup-oras@v1 |
| 183 | + |
| 184 | + - name: tools - oras - login - ghcr.io |
| 185 | + run: echo "${{ secrets.ES_GITHUB_PAT }}" | oras login ghcr.io -u ${{ github.actor }} --password-stdin |
| 186 | + |
| 187 | + - name: Find and inspect all .tgz Helm charts in .artifacts/helm |
| 188 | + run: | |
| 189 | + set -euo pipefail |
| 190 | +
|
| 191 | + echo "🔍 Searching for .tgz Helm charts in '.artifacts/helm/'..." |
| 192 | + find .artifacts/helm -type f -name '*.tgz' | while read -r chart; do |
| 193 | + echo "📦 Chart file: $chart" |
| 194 | +
|
| 195 | + # Extract chart metadata |
| 196 | + metadata=$(helm show chart "$chart") |
| 197 | + name=$(echo "$metadata" | awk '/^name:/ { print $2 }') |
| 198 | + version=$(echo "$metadata" | awk '/^version:/ { print $2 }') |
| 199 | +
|
| 200 | + echo " → Name: $name" |
| 201 | + echo " → Version: $version" |
| 202 | +
|
| 203 | + helm push "$chart" ${{ env.helm_chart_repository_protocol }}${{ env.helm_chart_repository }} |
| 204 | + done |
| 205 | +
|
| 206 | + - name: github - release - create |
| 207 | + uses: softprops/action-gh-release@v2 |
| 208 | + with: |
| 209 | + repository: ${{ github.repository }} |
| 210 | + name: v${{ env.gitVersion_SemVer }} |
| 211 | + tag_name: v${{ env.gitVersion_SemVer }} |
| 212 | + body: The release process is automated. |
| 213 | + generate_release_notes: true |
| 214 | + token: ${{ secrets.ES_GITHUB_PAT }} |
| 215 | + |
| 216 | + - name: Repository Dispatch |
| 217 | + uses: peter-evans/repository-dispatch@v3 |
| 218 | + with: |
| 219 | + token: ${{ secrets.ES_GITHUB_PAT }} |
| 220 | + repository: emberstack/helm-charts |
| 221 | + event-type: release |
| 222 | + client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}"}' |
| 223 | + |
0 commit comments