Skip to content

Commit

Permalink
Automate pre-releases
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Prescod committed Feb 17, 2023
1 parent b5fe2d6 commit 4649506
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 0 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/prerelease.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Update Python Dependencies

on: [workflow_dispatch]

jobs:
update_dependencies:
runs-on: sfdc-ubuntu-latest
steps:
- name: "Checkout"
uses: actions/checkout@v3
with:
ref: main
fetch-depth: 0
- name: Set up Python ${{ inputs.python-version }}
id: py
uses: actions/setup-python@v4
with:
python-version: ${{ inputs.python-version }}
cache: pip
cache-dependency-path: "requirements/*.txt"
- name: Update dependencies
run: |
pip install pip-tools
make update-deps
- name: Commit dependency changes and open PR
run: |
export DAY="$(date -I)"
git config user.name github-actions
git config user.email github-actions@github.com
git switch prerelease || git switch -c prerelease
git add requirements/*.txt
git commit -m "$DAY dependency updates (automated)" || true
git push
- name: Generate release notes
id: changelog
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
export DAY="$(date -I)"
PREVIOUS_VERSION=$(gh release view --json tagName --jq .tagName)
NEXT_VERSION="v$(head -n 1 snowfakery/version.txt)"
echo "## $NEXT_VERSION ($(date -I))" > changelog.md
gh api \
--method POST \
-H "Accept: application/vnd.github.v3+json" \
/repos/SFDO-Tooling/CumulusCI/releases/generate-notes \
-f previous_tag_name=$PREVIOUS_VERSION \
-f target_commitish='main' \
-f tag_name=$NEXT_VERSION \
--jq '.body' | \
sed -e 's_\(https.*\/\)\([0-9]*\)$_[#\2](\1\2)_' \
-e 's_by @\(.*\) in_by [@\1](https://github.com/\1) in_' >> changelog.md
python utility/update-history.py
git commit -m "$DAY history updates" || true
git push
- env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr view || gh pr create --fill --label 'auto-pr,dependencies'
1 change: 1 addition & 0 deletions tools/TODO.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Todo: move tools/* into utility/* to match CCI
20 changes: 20 additions & 0 deletions utility/update-history.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"""
Update the history file.
"""
from pathlib import Path
import re

START_MARKER = "<!-- latest-start -->"
STOP_MARKER = "<!-- latest-stop -->"

history = Path("HISTORY.md").read_text()
latest = Path("changelog.md").read_text()
print(re.findall(f"{START_MARKER}.*", history, flags=re.DOTALL))
updated = re.sub(
f"{START_MARKER}.*{STOP_MARKER}",
f"{START_MARKER}\n{latest}\n{STOP_MARKER}",
history,
flags=re.DOTALL,
)

Path("HISTORY.md").write_text(updated)

0 comments on commit 4649506

Please sign in to comment.