Skip to content

Commit 9445871

Browse files
authored
Merge pull request #65 from thenewguy/fix-release-by-tag
release by tag
2 parents 8067720 + 51acfc3 commit 9445871

File tree

2 files changed

+52
-12
lines changed

2 files changed

+52
-12
lines changed

.github/workflows/python-publish.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ on:
99

1010
jobs:
1111
deploy:
12-
12+
if: startsWith(github.ref, 'refs/tags/v')
1313
runs-on: ubuntu-latest
14-
1514
steps:
1615
- uses: actions/checkout@v2
1716
- name: Set up Python

.github/workflows/tox.yml .github/workflows/sdist.yml

+51-10
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
name: Tox
1+
name: Build, Test, and Release sdist
2+
3+
# reference:
4+
# - https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#contexts
5+
# - https://docs.github.com/en/actions/reference/environment-variables
26

37
on: [push]
48

@@ -51,17 +55,17 @@ jobs:
5155
- name: Display structure of downloaded files
5256
run: ls -aR ~/.toxsdistsrc/
5357
- name: Rename file
54-
run: mv ~/.toxsdistsrc/django-tellme-*.zip /tmp/django-tellme-pre-${{ github.run_number }}-${{ github.sha }}.zip
58+
run: mv ~/.toxsdistsrc/django-tellme-*.zip /tmp/django-tellme-sdist-${{ github.run_number }}-${{ github.sha }}.zip
5559
- name: Display tmp files
5660
run: ls /tmp
5761
- name: Run Tox
5862
# Run tox using the version of Python in `PATH`
59-
run: python -m tox -vv --installpkg "/tmp/django-tellme-pre-${{ github.run_number }}-${{ github.sha }}.zip"
63+
run: python -m tox -vv --installpkg "/tmp/django-tellme-sdist-${{ github.run_number }}-${{ github.sha }}.zip"
6064
env:
6165
DJANGO: ${{ matrix.django }}
6266

63-
prerelease:
64-
if: contains(github.event.head_commit.message, '[prerelease]')
67+
pre-release:
68+
if: startsWith(github.ref, 'refs/tags/p')
6569
needs: test
6670
runs-on: ubuntu-latest
6771
steps:
@@ -73,7 +77,7 @@ jobs:
7377
- name: Display structure of downloaded files
7478
run: ls -aR ~/.toxsdistsrc/
7579
- name: Rename file
76-
run: mv ~/.toxsdistsrc/django-tellme-*.zip /tmp/django-tellme-pre-${{ github.run_number }}-${{ github.sha }}.zip
80+
run: mv ~/.toxsdistsrc/django-tellme-*.zip /tmp/django-tellme-sdist-${{ github.run_number }}-${{ github.sha }}.zip
7781
- name: Display tmp files
7882
run: ls /tmp
7983
- name: Create Release
@@ -82,8 +86,8 @@ jobs:
8286
env:
8387
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8488
with:
85-
tag_name: pre-${{ github.run_number }}-${{ github.sha }}
86-
release_name: Pre-release ${{ github.run_number }}
89+
tag_name: ${{ github.ref }}
90+
release_name: Pre-release ${{ github.ref }}
8791
draft: false
8892
prerelease: true
8993
- name: Upload Release Asset
@@ -93,6 +97,43 @@ jobs:
9397
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9498
with:
9599
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
96-
asset_path: /tmp/django-tellme-pre-${{ github.run_number }}-${{ github.sha }}.zip
97-
asset_name: django-tellme-pre-${{ github.run_number }}-${{ github.sha }}.zip
100+
asset_path: /tmp/django-tellme-sdist-${{ github.run_number }}-${{ github.sha }}.zip
101+
asset_name: django-tellme-sdist-${{ github.run_number }}-${{ github.sha }}.zip
102+
asset_content_type: application/zip
103+
104+
release:
105+
if: startsWith(github.ref, 'refs/tags/v')
106+
needs: test
107+
runs-on: ubuntu-latest
108+
steps:
109+
- name: Download sdist
110+
uses: actions/download-artifact@v2
111+
with:
112+
name: sdist
113+
path: ~/.toxsdistsrc/
114+
- name: Display structure of downloaded files
115+
run: ls -aR ~/.toxsdistsrc/
116+
- name: Rename file
117+
run: mv ~/.toxsdistsrc/django-tellme-*.zip /tmp/django-tellme-sdist-${{ github.run_number }}-${{ github.sha }}.zip
118+
- name: Display tmp files
119+
run: ls /tmp
120+
- name: Create Release
121+
id: create_release
122+
uses: actions/create-release@v1
123+
env:
124+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
125+
with:
126+
tag_name: ${{ github.ref }}
127+
release_name: Release ${{ github.ref }}
128+
draft: false
129+
prerelease: false
130+
- name: Upload Release Asset
131+
id: upload-release-asset
132+
uses: actions/upload-release-asset@v1
133+
env:
134+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
135+
with:
136+
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
137+
asset_path: /tmp/django-tellme-sdist-${{ github.run_number }}-${{ github.sha }}.zip
138+
asset_name: django-tellme-sdist-${{ github.run_number }}-${{ github.sha }}.zip
98139
asset_content_type: application/zip

0 commit comments

Comments
 (0)