Skip to content

Commit

Permalink
Auto-create release on tag, with manifests
Browse files Browse the repository at this point in the history
Releases are created when a v* tag is pushed to the releases/v0 branch.

As part of the release, the manifests from each of the submodules, and also
from cert-manager and mpi-operator, are collected into a tarball and included
as a release artifact.  This tarball is meant to be unpacked in a gitops repo.

Signed-off-by: Dean Roehrich <[email protected]>
  • Loading branch information
roehrich-hpe committed Jan 22, 2024
1 parent 1edfc23 commit 9502500
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 28 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/handle_release_tag.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Handle Release Tag

on:
push:
tags:
- 'v*'

jobs:
create_release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
fetch-tags: true
fetch-depth: 0
- name: Repair tag
run: git fetch -f origin ${{ github.ref }}:${{ github.ref }}
- name: Verify that the tag is annotated
run: if test x$(git for-each-ref ${{ github.ref }} | awk '{print $2}') = xtag; then /bin/true; else echo "\"${{ github.ref }}\" does not look like an annotated tag!"; /bin/false; fi
- name: Submodule status
run: git submodule status
- name: Collect manifests
run: tools/collect-manifests.sh ~+/release-manifests
- name: Make tarball
run: cd release-manifests && tar cvf ../manifests.tar *
- name: Release
uses: softprops/action-gh-release@v1
with:
#prerelease: true
generate_release_notes: true
files: manifests.tar

28 changes: 0 additions & 28 deletions .github/workflows/verify_tag.yml

This file was deleted.

76 changes: 76 additions & 0 deletions tools/collect-manifests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#!/bin/bash

# Copyright 2024 Hewlett Packard Enterprise Development LP
# Other additional copyright holders may be indicated within.
#
# The entirety of this work is licensed under the Apache License,
# Version 2.0 (the "License"); you may not use this file except
# in compliance with the License.
#
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

TREEDIR="$1"

if [[ -z $TREEDIR ]]; then
echo "specify a tree dir"
exit 1
elif [[ $TREEDIR != /* ]]; then
echo "must begin with a slash"
exit 1
elif [[ -d $TREEDIR ]]; then
echo "the dir already exists"
exit 1
fi

mkdir "$TREEDIR"
DO_MODULES=""
SUBMODULES=$(git submodule status | awk '{print $2}')

for SUBMODULE in $SUBMODULES; do
if grep -qE '^edit-image:' "$SUBMODULE"/Makefile
then
echo "Generating the manifest from $SUBMODULE"
if ! make -C "$SUBMODULE" edit-image kustomize; then
echo "Stopping at $SUBMODULE"
exit 1
fi
DO_MODULES="$DO_MODULES $SUBMODULE"
fi
done

for SUBMODULE in $DO_MODULES; do
echo "Collecting the manifest from $SUBMODULE"
mkdir "$TREEDIR/$SUBMODULE"
(cd "$SUBMODULE" || exit 1
if [[ -d config/begin ]]; then
bin/kustomize build config/begin > "$TREEDIR/$SUBMODULE/$SUBMODULE.yaml"
fi
if [[ -d config/begin-examples ]]; then
bin/kustomize build config/begin-examples > "$TREEDIR/$SUBMODULE/$SUBMODULE-examples.yaml"
fi
if [[ -d config/prometheus ]]; then
bin/kustomize build config/prometheus > "$TREEDIR/$SUBMODULE/$SUBMODULE-prometheus.yaml"
fi
if [[ -d deploy/kubernetes/begin ]]; then
bin/kustomize build deploy/kubernetes/begin > "$TREEDIR/$SUBMODULE/$SUBMODULE.yaml"
fi
)
done

mkdir "$TREEDIR/cert-mgr"
CERT_URL=$(yq -M '.thirdPartyServices[] | select(.name == "cert-manager") | .url' config/repositories.yaml)
wget -O "$TREEDIR"/cert-mgr/cert-mgr.yaml "$CERT_URL"

mkdir "$TREEDIR/mpi-operator"
MPIOP_URL=$(yq -M '.thirdPartyServices[] | select(.name == "mpi-operator") | .url' config/repositories.yaml)
wget -O "$TREEDIR"/mpi-operator/mpi-operator.yaml "$MPIOP_URL"


0 comments on commit 9502500

Please sign in to comment.