Weekly Update and Publish #7
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: Weekly Update and Publish | |
on: | |
schedule: | |
- cron: "0 0 * * 0" # Run at midnight UTC every Sunday | |
workflow_dispatch: # Allow manual triggering of the workflow | |
jobs: | |
update-and-publish: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: [3.9] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Configure git | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "Christina Hedges" | |
- name: Set CI environment variable | |
run: echo "CI=true" >> $GITHUB_ENV | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Cache Poetry dependencies | |
uses: actions/cache@v3 | |
with: | |
path: ~/.cache/pypoetry | |
key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }} | |
restore-keys: | | |
${{ runner.os }}-poetry- | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install poetry | |
poetry install --with dev --extras "database" | |
- name: Run the update function | |
id: run-update | |
run: | | |
poetry run python -c "from tesswcs.database import _build_wcs_database; _build_wcs_database()" | |
poetry run python -c "from tesswcs.database import _build_warp_matrices; _build_warp_matrices()" | |
- name: Check for changes | |
id: check-changes | |
run: | | |
if git diff --quiet; then | |
echo "changes=false" >> $GITHUB_ENV | |
else | |
echo "changes=true" >> $GITHUB_ENV | |
fi | |
- name: Set up Git | |
if: env.changes == 'true' | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "GitHub Actions" | |
- name: Authenticate with GITHUB_TOKEN | |
if: env.changes == 'true' | |
run: | | |
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/tessgi/tesswcs.git | |
- name: Commit Changes | |
if: env.changes == 'true' | |
run: | | |
git add . | |
git commit -m "Automated update of internal database" | |
- name: Bump version | |
if: env.changes == 'true' | |
run: | | |
poetry version patch # Bump the version (use `major`, `minor`, or `patch` as needed) | |
git add pyproject.toml | |
git commit -m "Bump version" | |
- name: Push Changes | |
if: env.changes == 'true' | |
run: | | |
git push origin main --tags | |
- name: Publish to PyPI | |
if: env.changes == 'true' | |
env: | |
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_API_TOKEN }} | |
run: | | |
poetry build | |
poetry publish | |
- name: Create GitHub Release | |
if: env.changes == 'true' | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: v${{ steps.bump-version.outputs.new_version }} | |
release_name: Release v${{ steps.bump-version.outputs.new_version }} | |
body: | | |
Automated release for version v${{ steps.bump-version.outputs.new_version }}. | |
draft: false | |
prerelease: false |