|
1 | 1 | # This workflows will upload a Python Package using Twine when a release is created |
2 | 2 | # For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries |
3 | | - |
4 | 3 | name: Release to PyPi and DockerHub |
5 | 4 |
|
6 | 5 | on: |
7 | 6 | release: |
8 | 7 | types: [published, edited] |
9 | 8 |
|
| 9 | +# https://blog.pypi.org/posts/2023-04-20-introducing-trusted-publishers/ |
| 10 | +permissions: |
| 11 | + contents: read |
| 12 | + id-token: write |
| 13 | + |
10 | 14 | jobs: |
11 | 15 | publish: |
12 | | - runs-on: ubuntu-latest |
| 16 | + runs-on: ubuntu-22.04 |
13 | 17 | env: |
14 | 18 | RELEASE_REF: ${{ github.ref }} |
15 | 19 | steps: |
16 | | - - uses: actions/checkout@v2 |
| 20 | + - uses: actions/checkout@v4.1.1 |
17 | 21 | - name: Set up Python |
18 | | - uses: actions/setup-python@v1 |
| 22 | + uses: actions/setup-python@v4 |
19 | 23 | with: |
20 | 24 | python-version: "3.9" |
| 25 | + cache: pip |
21 | 26 | - name: Inject slug/short variables |
22 | | - uses: rlespinasse/github-slug-action@3.0.0 |
| 27 | + uses: rlespinasse/github-slug-action@v4 |
23 | 28 | - name: Set Release Version |
24 | 29 | run: | |
25 | 30 | export RELEASE_VERSION=${GITHUB_REF_SLUG} |
26 | 31 | echo -n $RELEASE_VERSION > ./version |
27 | 32 | echo "RELEASE_VERSION=${RELEASE_VERSION}" >> $GITHUB_ENV |
28 | | - export _DOCKER_TAG="unfor19/audacity-scripting:${RELEASE_VERSION}" |
29 | | - echo "DOCKER_TAG=${_DOCKER_TAG}" >> $GITHUB_ENV |
30 | 33 | - name: Validate Release Version |
31 | 34 | run: | |
32 | 35 | echo $GITHUB_ENV |
33 | 36 | bash scripts/version_validation.sh |
34 | 37 | - name: Install dependencies |
35 | 38 | run: | |
36 | 39 | python -m pip install --upgrade pip |
37 | | - pip install setuptools==50.3.2 wheel==0.35.1 twine==3.1.1 |
38 | | - pip install -r requirements.txt |
39 | | - - name: Test |
40 | | - run: | |
41 | | - python -m unittest discover -s tests -v |
| 40 | + pip install setuptools wheel twine |
42 | 41 | - name: Build Package |
43 | 42 | run: | |
44 | 43 | python setup.py sdist bdist_wheel |
45 | 44 | twine check ./dist/* |
46 | 45 | - name: Publish to PyPi |
47 | 46 | env: |
48 | | - TWINE_USERNAME: ${{ secrets.PIP_USERNAME }} |
49 | | - TWINE_PASSWORD: ${{ secrets.PIP_PASSWORD }} |
50 | 47 | TWINE_NON_INTERACTIVE: true |
51 | 48 | run: | |
52 | 49 | twine upload ./dist/* |
53 | | - - name: Build Docker Image |
54 | | - run: | |
55 | | - docker build . --file Dockerfile --tag "${DOCKER_TAG}" |
56 | | - - name: Push to DockerHub |
57 | | - run: | |
58 | | - echo '${{ secrets.DOCKER_PASSWORD }}' | docker login --username ${{ secrets.DOCKER_USERNAME }} --password-stdin |
59 | | - docker push "${DOCKER_TAG}" && echo "Pushed $DOCKER_TAG" |
0 commit comments