format('{{"{0}", {1}}}', github.ref, toJSON(inputs)) #37
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release | |
run-name: "format('{{\"{0}\", {1}}}', github.ref, toJSON(inputs))" | |
concurrency: | |
cancel-in-progress: true | |
group: release | |
on: | |
workflow_dispatch: | |
inputs: | |
release_title: | |
description: Title | |
required: true | |
type: string | |
jobs: | |
Bump: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 # for git log | |
- name: New Version | |
id: new_version | |
run: date $'+NEW_TAG=%Y-%m-%d\nNEW_VERSION=%-Y.%-m.%-d' |tee -a "$GITHUB_OUTPUT" | |
- name: Last Tag | |
id: last_tag | |
env: | |
NEW_TAG: "${{ steps.new_version.outputs.NEW_TAG }}" | |
run: | | |
set -euxo pipefail | |
if git tag |grep -q "$NEW_TAG"; then | |
echo "::error::Tag $NEW_TAG already exists" >&2 | |
exit 1 | |
fi | |
git tag | | |
grep -E '^[0-9]{4}-[0-9]{2}-[0-9]{2}$' | | |
sort -r |head -1 | | |
xargs -I {} echo "LAST_TAG={}"| | |
tee -a "$GITHUB_OUTPUT" | |
- name: Git Log | |
id: git_log | |
env: | |
LAST_TAG: "${{ steps.last_tag.outputs.LAST_TAG }}" | |
run: | | |
set -euxo pipefail | |
{ | |
echo "GIT_LOG<<EOFEOFEOF" | |
git log --pretty="* %h %s" "$LAST_TAG..HEAD" |tee cl_body.md | |
echo EOFEOFEOF | |
} |tee -a "$GITHUB_OUTPUT" | |
- name: Generate Changelog Entry | |
env: | |
NEW_VERSION: "${{ steps.new_version.outputs.NEW_VERSION }}" | |
TITLE: "${{ inputs.release_title }}" | |
run: | | |
set -euxo pipefail | |
test -n "$TITLE" | |
{ | |
echo "## [$NEW_VERSION]" | |
echo | |
echo "$TITLE" | |
echo | |
cat cl_body.md | |
echo | |
} |tee cl_entry.md | |
- name: Update CHANGELOG.md | |
run: | | |
set -eux | |
awk ' | |
NR==FNR {content[NR]=$0; next} | |
/^## \[/ { | |
if (!p) { | |
for (i=1;i<=length(content);i++) print content[i] | |
p=1 | |
} | |
} 1 | |
' cl_entry.md CHANGELOG.md > CHANGELOG2.md | |
mv CHANGELOG2.md CHANGELOG.md | |
- name: Update Version File | |
env: | |
NEW_VERSION: "${{ steps.new_version.outputs.NEW_VERSION }}" | |
PATTERN: '[0-9]\{4\}[.][0-9]\{1,2\}[.][0-9]\{1,2\}' | |
run: sed -i "0,/^version = /s/\"$PATTERN\"/\"$NEW_VERSION\"/" pyproject.toml | |
- name: Commit and Push | |
id: commit | |
uses: stefanzweifel/git-auto-commit-action@v5 | |
with: | |
commit_message: "${{ steps.new_version.outputs.NEW_VERSION }}: ${{ inputs.release_title }}" | |
file_pattern: CHANGELOG.md pyproject.toml | |
outputs: | |
GIT_LOG: "${{ steps.git_log.outputs.GIT_LOG }}" | |
NEW_COMMIT: "${{ steps.commit.outputs.commit_hash }}" | |
NEW_TAG: "${{ steps.new_version.outputs.NEW_TAG }}" | |
Deploy: | |
needs: Bump | |
uses: ./.github/workflows/deploy.yml | |
with: | |
commit: "${{ needs.Bump.outputs.NEW_COMMIT }}" # TODO verify with HTML changes and grep the tgz file and check r86s | |
production: true | |
sphinx_github_branch: "${{ github.ref_name }}" | |
secrets: inherit | |
Release: # TODO protect all tags dddd-dd-dd | |
needs: [Bump, Deploy] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download HTML | |
uses: actions/download-artifact@v3 | |
with: | |
name: html | |
path: html | |
- name: Archive HTML | |
run: tar -czf html.tar.gz html | |
- name: Create Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
name: "${{ inputs.release_title }}" | |
body: "${{ needs.Bump.outputs.GIT_LOG }}" | |
files: html.tar.gz | |
tag_name: "${{ needs.Bump.outputs.NEW_TAG }}" | |
fail_on_unmatched_files: true | |
target_commitish: "${{ needs.Bump.outputs.NEW_COMMIT }}" | |
# TODO: | |
# 1. Checkout | |
# 2. Deps | |
# 3. Build | |
# 4. upload artifact | |
# 5. get version (2023.9.30) | |
# 1. look for version in changelog file | |
# 6. get title for version from changelog file | |
# 7. get description/body of changelog for this version | |
# 8. deploy | |
# 9. make a gh release | |
# ------------------------------------------------------------------------ | |
# Change changelog to this format: | |
# ## [YYYY.M.D] | |
# inputs.release_title | |
# - [commitsha] commit title (#PR) | |
# - [commitsha] commit title (#PR) | |
# - [commitsha] commit title (#PR) | |
# - [commitsha] commit title (#PR) | |
# ------------------------------------------------------------------------ | |
# 1. generate changelog (genVersion inputsTitle genDescription) | |
# 1. prepend to CHANGELOG.md and update __version__ | |
# 1. commit to branch | |
# 2. call_workflow deploy [prod=true] (checkout deps build uploadArtifact deploy2prod) | |
# 3. make a gh release [create tag] |