Skip to content

Build Release

Build Release #1

name: Build Release
on:
workflow_dispatch:
inputs:
version:
description: "Release version"
required: true
branch:
description: "Branch to build from"
required: false
default: "main"
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ inputs.branch }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install towncrier
- name: Generate draft release notes with Towncrier
run: |
towncrier build --draft --version "${{ inputs.version }}" > draft_release_notes.md
- name: Generate final release notes with Towncrier
run: |
towncrier build --version "${{ inputs.version }}" --yes
- name: Update pyproject.toml with new version
run: |
sed -i '/^\[project\]/,/^version = / s/^version = ".*"$/version = "${{ inputs.version }}"/' pyproject.toml
- name: Update environment.yaml with new tag
run: |
sed -i 's|git+https://github.com/gemini-hlsw/goats.git@.*|git+https://github.com/gemini-hlsw/goats.git@${{ inputs.version }}|' environment.yaml
- name: Commit updated changelog
run: |
set -e
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add pyproject.toml environment.yaml
# Ensure CHANGES.md exists before adding it
if [ -f CHANGES.md ]; then
git add CHANGES.md
fi
git commit -m "Update version to ${{ inputs.version }} and generate release notes." || echo "No changes to commit."
git push origin ${{ inputs.branch }}
- name: Create tag
run: |
git tag -a "${{ inputs.version }}" -m "Release ${{ inputs.version }}."
git push origin "${{ inputs.version }}"
- name: Create GitHub release and upload artifacts
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ inputs.version }}
name: ${{ inputs.version }}
draft: true # Set to true to create a draft release.
prerelease: false
body_path: draft_release_notes.md