Skip to content

v1.3.1

v1.3.1 #18

Workflow file for this run

name: Build Release
on:
release:
types: [published]
env:
IAC: ${GITHUB_REPOSITORY#${GITHUB_REPOSITORY_OWNER}/}-iac
SRC: ${GITHUB_REPOSITORY#${GITHUB_REPOSITORY_OWNER}/}-src
jobs:
build-release:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
id-token: write
steps:
- name: Output Environment
run: |
echo "IAC: ${{ env.IAC }}"
echo "SRC: ${{ env.SRC }}"
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Validate and Extract Version from Tag
id: version
run: |
TAG_NAME=${GITHUB_REF_NAME}
if [[ ! $TAG_NAME =~ ^v[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
echo "Invalid tag name format: $TAG_NAME"
echo "Must be in the format vMAJOR.MINOR.PATCH (e.g. v1.2.3)"
exit 1
fi
VERSION=${TAG_NAME#v}
echo "Tag validated: $TAG_NAME"
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
- name: Inject Static Version into _version.py, versions.tf, and Chart.yaml
run: |
echo "__version__ = \"$VERSION\"" > src/common/_version.py
sed -i "s/app_version[[:space:]]*=[[:space:]]*\".*\"/app_version = \"$VERSION\"/" opentofu/versions.tf
sed -i "s/^version:[[:space:]]*.*$/version: $VERSION/" helm/Chart.yaml
sed -i "s/^appVersion:[[:space:]]*\".*\"$/appVersion: \"$VERSION\"/" helm/Chart.yaml
echo "Injected version:"
cat src/common/_version.py
cat opentofu/versions.tf
cat helm/Chart.yaml
env:
VERSION: ${{ steps.version.outputs.VERSION }}
- name: Build and Push Source
run: |
zip -r $RUNNER_TEMP/${{ env.SRC }}.zip src pyproject.toml .dockerignore
tar -czf "$RUNNER_TEMP/${{ env.SRC }}.tar.gz" src pyproject.toml .dockerignore
gh release upload ${{github.event.release.tag_name}} "$RUNNER_TEMP/${{ env.SRC }}.zip" --clobber
gh release upload ${{github.event.release.tag_name}} "$RUNNER_TEMP/${{ env.SRC }}.tar.gz" --clobber
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RUNNER_TEMP: ${{ runner.temp }}
shell: bash
- name: Build and Push Infrastructure as Code
run: |
cd opentofu
zip -r $RUNNER_TEMP/${{ env.IAC }}.zip . -x "terraform*" ".terraform*" "*/terraform*" "*/.terraform*" "cfgmgt/stage/*.*"
gh release upload ${{github.event.release.tag_name}} "$RUNNER_TEMP/${{ env.IAC }}.zip" --clobber
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RUNNER_TEMP: ${{ runner.temp }}
shell: bash