1- name : test
1+ name : ci-cd
22
33on :
44 push :
55 pull_request :
66 workflow_dispatch :
77 schedule :
8- # Weekly build (on branch main) every Thursday at 12:00 UTC.
8+ # Weekly test (on branch main) every Thursday at 12:00 UTC.
99 # (Used to monitor compatibility with ESP APIs and other dependencies.)
1010 - cron : ' 0 12 * * 4'
1111
1212
1313jobs :
1414 skip_duplicate_runs :
15- # Avoid running the tests twice on the same code
16- # (particularly live integration tests that eat up ESP test quota )
17- runs-on : ubuntu-18 .04
15+ # Avoid running the live integration tests twice on the same code
16+ # (to conserve limited sending quotas in the live ESP test accounts )
17+ runs-on : ubuntu-20 .04
1818 outputs :
1919 should_skip : ${{ steps.skip_check.outputs.should_skip }}
2020 steps :
2121 - id : skip_check
22- # uses: fkirc/skip-duplicate-actions@v3.3 .0
23- uses : fkirc/skip-duplicate-actions@ea548f2a2a08c55dcb111418ca62181f7887e297
22+ # uses: fkirc/skip-duplicate-actions@v3.4 .0
23+ uses : fkirc/skip-duplicate-actions@4c656bbdb6906310fa6213604828008bc28fe55d
2424 with :
2525 concurrent_skipping : " same_content"
2626 skip_after_successful_duplicate : " true"
2929
3030 test :
3131 name : ${{ matrix.config.tox }} ${{ matrix.config.options }}
32- runs-on : ubuntu-18 .04
32+ runs-on : ubuntu-20 .04
3333 needs : skip_duplicate_runs
34- if : ${{ needs.skip_duplicate_runs.outputs.should_skip != 'true' }}
3534 timeout-minutes : 15
3635 strategy :
3736 fail-fast : false
@@ -105,7 +104,7 @@ jobs:
105104 # for installing/running tox
106105 uses : actions/setup-python@v2
107106 with :
108- python-version : 3.8
107+ python-version : 3.9
109108 - name : Install tox
110109 run : |
111110 set -x
@@ -114,13 +113,16 @@ jobs:
114113 tox --version
115114 - name : Test ${{ matrix.config.tox }}
116115 run : |
117- tox --version
118116 tox -e ${{ matrix.config.tox }}
119117 continue-on-error : ${{ contains( matrix.config.options, 'allow-failures' ) }}
120118 env :
121119 CONTINUOUS_INTEGRATION : true
122120 TOX_FORCE_IGNORE_OUTCOME : false
123- ANYMAIL_RUN_LIVE_TESTS : ${{ contains( matrix.config.options, 'run-live-tests' ) }}
121+ ANYMAIL_RUN_LIVE_TESTS : >-
122+ ${{
123+ contains( matrix.config.options, 'run-live-tests' )
124+ && needs.skip_duplicate_runs.outputs.should_skip != 'true'
125+ }}
124126 ANYMAIL_TEST_AMAZON_SES_ACCESS_KEY_ID : ${{ secrets.ANYMAIL_TEST_AMAZON_SES_ACCESS_KEY_ID }}
125127 ANYMAIL_TEST_AMAZON_SES_REGION_NAME : ${{ secrets.ANYMAIL_TEST_AMAZON_SES_REGION_NAME }}
126128 ANYMAIL_TEST_AMAZON_SES_SECRET_ACCESS_KEY : ${{ secrets.ANYMAIL_TEST_AMAZON_SES_SECRET_ACCESS_KEY }}
@@ -135,3 +137,79 @@ jobs:
135137 ANYMAIL_TEST_SENDGRID_TEMPLATE_ID : ${{ secrets.ANYMAIL_TEST_SENDGRID_TEMPLATE_ID }}
136138 ANYMAIL_TEST_SENDINBLUE_API_KEY : ${{ secrets.ANYMAIL_TEST_SENDINBLUE_API_KEY }}
137139 ANYMAIL_TEST_SPARKPOST_API_KEY : ${{ secrets.ANYMAIL_TEST_SPARKPOST_API_KEY }}
140+
141+ identify_tag :
142+ # If the (exact) ref on which this workflow is running is tagged,
143+ # set outputs.tag to the tag; otherwise set it to an empty string
144+ runs-on : ubuntu-20.04
145+ outputs :
146+ tag : ${{ steps.get_tag.outputs.tag }}
147+ steps :
148+ - name : Get code
149+ uses : actions/checkout@v2
150+ - name : Identify git tag
151+ id : get_tag
152+ run : |
153+ TAG=$(git describe --tags --exact-match "$GITHUB_REF" 2>/dev/null || echo "")
154+ echo "::set-output name=tag::$TAG"
155+ echo "github ref: $GITHUB_REF"
156+ echo "tag: ${TAG:-(no tag)}"
157+
158+ release :
159+ # Release on push or manual trigger of ref that is a v* tag
160+ runs-on : ubuntu-20.04
161+ needs :
162+ - identify_tag
163+ - test
164+ if : >-
165+ startsWith(needs.identify_tag.outputs.tag, 'v')
166+ && (github.event_name == 'push'
167+ || github.event_name == 'workflow_dispatch')
168+ steps :
169+ - name : Get code
170+ uses : actions/checkout@v2
171+ - name : Setup Python
172+ uses : actions/setup-python@v2
173+ with :
174+ python-version : 3.9
175+ - name : Check package version
176+ id : version
177+ env :
178+ TAG : ${{ needs.identify_tag.outputs.tag }}
179+ run : |
180+ VERSION="v$(python setup.py --version)"
181+ if [ "$VERSION" != "$TAG" ]; then
182+ echo "::error ::package version '$VERSION' does not match git tag '$TAG'"
183+ exit 1
184+ fi
185+ echo "::set-output name=version::$VERSION"
186+ echo "::set-output name=anchor::${VERSION//[^[:alnum:]]/-}"
187+ - name : Install build requirements
188+ run : |
189+ pip install twine wheel
190+ - name : Build
191+ run : |
192+ rm -rf build dist django_anymail.egg-info
193+ python setup.py sdist bdist_wheel
194+ twine check dist/*
195+ - name : Publish package to PyPI
196+ env :
197+ TWINE_USERNAME : __token__
198+ TWINE_PASSWORD : ${{ secrets.PYPI_API_TOKEN }}
199+ run : |
200+ twine upload dist/*
201+ - name : Publish release to GitHub
202+ env :
203+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
204+ TAG : ${{ steps.version.outputs.version }}
205+ TITLE : ${{ steps.version.outputs.version }}
206+ NOTES : |
207+ [Changelog](https://anymail.readthedocs.io/en/stable/changelog/#${{ steps.version.outputs.anchor }})
208+ run : |
209+ # gh release create-or-edit "$TAG" --title "$TITLE" --notes "$NOTES" ./dist/*
210+ # (gh release doesn't support edit - 6/2021)
211+ # (hub requires separate --attach=FILE arg for each file)
212+ FILES=(./dist/*)
213+ if ! hub release edit --message "$TITLE" --message "$NOTES" "${FILES[@]/#/--attach=}" "$TAG"; then
214+ hub release create --message "$TITLE" --message "$NOTES" "${FILES[@]/#/--attach=}" "$TAG"
215+ fi
0 commit comments