Skip to content
Open
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
47 changes: 47 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#
# Copyright (c) Microsoft Corporation
# Licensed under the MIT License.
#
name: product-release

on:
push:
tags:
- '*'

defaults:
run:
shell: bash

jobs:
release:
runs-on: ubuntu-latest
if: github.repository == 'Azure/cyclecloud-open-ondemand'
permissions:
contents: write

env:
VERSION: ${{ github.ref_name }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}

- name: Validate release tag
run: |
set -euo pipefail
chmod +x ./release.sh
./release.sh "$VERSION"

- name: Publish GitHub Release
uses: softprops/action-gh-release@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag_name: ${{ env.VERSION }}
prerelease: true
make_latest: false
generate_release_notes: true
2 changes: 1 addition & 1 deletion project.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[project]
name = ood
type = application
version = 1.1.4
version = 1.1.5
32 changes: 32 additions & 0 deletions release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash
set -euo pipefail

if [[ "${1:-}" == "" || "${1:-}" == "-h" || "${1:-}" == "--help" ]]; then
echo "Usage: $0 <release-tag>"
exit 1
fi

release_tag="$1"

# Resolve script directory so project.ini lookup works from any cwd.
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_INI="${SCRIPT_DIR}/project.ini"

if [[ ! -f "${PROJECT_INI}" ]]; then
echo "ERROR: Could not find ${PROJECT_INI}" >&2
exit 1
fi

project_version="$(awk -F '=' '/^[[:space:]]*version[[:space:]]*=/ { gsub(/^[[:space:]]+|[[:space:]]+$/, "", $2); print $2; exit }' "${PROJECT_INI}")"

if [[ "${project_version}" == "" ]]; then
echo "ERROR: Could not parse version from ${PROJECT_INI}" >&2
exit 1
fi

if [[ "${release_tag}" != "${project_version}" ]]; then
echo "ERROR: release tag '${release_tag}' does not match project.ini version '${project_version}'" >&2
exit 1
fi

echo "Validated: release tag '${release_tag}' matches project.ini version '${project_version}'."