Debian Codegraph @

.github/workflows/update_and_publish.yml

raw symbols SCIP
1 name: Update data files and publish
2
3 on:
4 schedule:
5 - cron: '0 0 * * MON'
6 workflow_dispatch:
7
8 jobs:
9
10 update:
11 name: Auto-update IERS tables
12 runs-on: ubuntu-latest
13 if: ${{ github.repository == 'astropy/astropy-iers-data' && github.ref_name == 'main' }}
14 outputs:
15 changed: ${{ steps.check.outputs.changed }}
16 new_sha: ${{ steps.commit.outputs.new_sha }}
17 steps:
18 - name: Checkout code
19 uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
20 - name: Download latest IERS files
21 run: ./scripts/update_data.sh
22 - name: Check for changes
23 id: check
24 run: |
25 if ! git diff --exit-code; then
26 echo "changed=true" > $GITHUB_OUTPUT
27 else
28 echo "changed=false" > $GITHUB_OUTPUT
29 fi
30
31 - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
32 if: steps.check.outputs.changed
33 with:
34 python-version: '3.x'
35
36 - name: Install tox
37 if: steps.check.outputs.changed
38 run: pip install tox
39
40 - name: Run preliminary tests
41 if: steps.check.outputs.changed
42 run: tox -e test
43
44 - name: Commit changes
45 id: commit
46 if: steps.check.outputs.changed
47 run: |
48 git config user.name github-actions
49 git config user.email [email protected]
50 git add astropy_iers_data/data
51 git commit -m "Update IERS Earth rotation and leap second tables"
52 git push
53 echo "new_sha=$(git rev-parse HEAD)" > $GITHUB_OUTPUT
54
55 tests:
56 name: Run tests on all platforms
57 needs: update
58 if: needs.update.outputs.changed
59 uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@2835f0cacddf3f8de198db9afdb5354a5cebe0ef # v2.6.3
60 with:
61 checkout_ref: ${{ needs.update.outputs.new_sha }}
62 envs: |
63 - linux: py310-test
64 - macos: py311-test
65 - windows: py312-test
66
67 tag:
68 name: Tag latest commit to main using calendar version
69 needs: [update, tests]
70 if: needs.update.outputs.changed
71 outputs:
72 new_tag: ${{ steps.tag_name.outputs.version }}
73 runs-on: ubuntu-latest
74 permissions:
75 contents: write
76 env:
77 GH_TOKEN: ${{ github.token }}
78 steps:
79 - name: Checkout code
80 uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
81 with:
82 ref: ${{ needs.update.outputs.new_sha }}
83 - name: Get tag name from date
84 id: tag_name
85 run: echo "version=v0.$(date +'%Y.%-m.%-d.%-H.%-M.%-S')" > $GITHUB_OUTPUT
86 - name: Check tag
87 run: echo ${{ steps.tag_name.outputs.version }}
88 - name: Create tag
89 uses: mathieudutour/github-tag-action@a22cf08638b34d5badda920f9daf6e72c477b07b # v6.2
90 with:
91 github_token: ${{ secrets.GITHUB_TOKEN }}
92 custom_tag: ${{ steps.tag_name.outputs.version }}
93 tag_prefix: ""
94 - name: Create GitHub release
95 run: gh release create ${{ steps.tag_name.outputs.version }} --generate-notes
96
97 publish:
98 name: Publish the release to PyPI
99 needs: [update, tag]
100 if: needs.update.outputs.changed
101 uses: OpenAstronomy/github-actions-workflows/.github/workflows/publish_pure_python.yml@2835f0cacddf3f8de198db9afdb5354a5cebe0ef # v2.6.3
102 with:
103 checkout_ref: ${{ needs.tag.outputs.new_tag }}
104 upload_to_pypi: true
105 secrets:
106 pypi_token: ${{ secrets.PYPI_TOKEN }}