|
1 | 1 | name: Deploy to PyPI
|
2 | 2 | on:
|
3 |
| - pull_request: |
4 |
| - branches: [master] |
5 |
| - types: [closed] |
6 |
| - workflow_dispatch: |
7 |
| - inputs: |
8 |
| - version_part: |
9 |
| - description: > |
10 |
| - Version part to bump before deployment. |
11 |
| - Possible options {none, major, minor, patch} |
12 |
| - required: true |
13 |
| - default: 'patch' |
| 3 | + push: |
| 4 | + tags: |
| 5 | + - "**" |
14 | 6 |
|
15 | 7 | jobs:
|
16 |
| - get_version_part_manually: |
17 |
| - name: Bump version on manual workflow dispatch |
18 |
| - if: github.event.inputs.version_part |
19 |
| - runs-on: ubuntu-latest |
20 |
| - env: |
21 |
| - VERSION_PART: ${{ github.event.inputs.version_part }} |
22 |
| - outputs: |
23 |
| - # will be empty if validation fails |
24 |
| - version_part: ${{ steps.validated_input.outputs.version_part }} |
25 |
| - steps: |
26 |
| - - name: Cancel on invalid input |
27 |
| - if: > |
28 |
| - !( |
29 |
| - env.VERSION_PART == 'none' || |
30 |
| - env.VERSION_PART == 'major' || |
31 |
| - env.VERSION_PART == 'minor' || |
32 |
| - env.VERSION_PART == 'patch' |
33 |
| - ) |
34 |
| - run: | |
35 |
| - echo "::error:: \`$VERSION_PART\` is not a valid version part. Must be one of {none, major, minor, patch}" |
36 |
| - exit 1 |
37 |
| - - name: Set version part based on manual input |
38 |
| - id: validated_input |
39 |
| - run: echo "::set-output name=version_part::$VERSION_PART" |
40 |
| - |
41 |
| - get_version_part_on_pr_merge: |
42 |
| - name: Bump version on pull reuqest merge |
43 |
| - if: github.event.pull_request.merged == true |
44 |
| - runs-on: ubuntu-latest |
45 |
| - outputs: |
46 |
| - version_part: ${{ join(steps.*.outputs.version_part, '') }} |
47 |
| - steps: |
48 |
| - - name: Cancel on bump:none |
49 |
| - id: bump_none |
50 |
| - if: contains(github.event.pull_request.labels.*.name, 'bump:none') |
51 |
| - run: echo "::set-output name=version_part::none" |
52 |
| - - name: Bump major |
53 |
| - id: bump_major |
54 |
| - if: > |
55 |
| - steps.bump_none.conclusion == 'skipped' && |
56 |
| - contains(github.event.pull_request.labels.*.name, 'bump:major') |
57 |
| - run: echo "::set-output name=version_part::major" |
58 |
| - - name: Bump minor |
59 |
| - id: bump_minor |
60 |
| - if: > |
61 |
| - steps.bump_none.conclusion == 'skipped' && |
62 |
| - steps.bump_major.conclusion == 'skipped' && |
63 |
| - contains(github.event.pull_request.labels.*.name, 'bump:minor') |
64 |
| - run: echo "::set-output name=version_part::minor" |
65 |
| - - name: Bump patch |
66 |
| - id: bump_patch |
67 |
| - if: > |
68 |
| - steps.bump_none.conclusion == 'skipped' && |
69 |
| - steps.bump_major.conclusion == 'skipped' && |
70 |
| - steps.bump_minor.conclusion == 'skipped' |
71 |
| - run: echo "::set-output name=version_part::patch" |
72 |
| - |
73 |
| - bump_version: |
74 |
| - name: Bump version |
75 |
| - needs: [get_version_part_on_pr_merge, get_version_part_manually] |
76 |
| - # always() needed to not automatically skip this job due to one of the |
77 |
| - # get_version_part_* jobs being skipped and bump_version depending on both. |
78 |
| - if: > |
79 |
| - always() && |
80 |
| - ( |
81 |
| - needs.get_version_part_on_pr_merge.result == 'success' || |
82 |
| - needs.get_version_part_manually.result == 'success' |
83 |
| - ) && |
84 |
| - join(needs.*.outputs.version_part, '') != 'none' |
85 |
| - env: |
86 |
| - VERSION_PART: ${{ join(needs.*.outputs.version_part, '') }} |
87 |
| - outputs: |
88 |
| - bumped_version_sha: > |
89 |
| - ${{ steps.save_bumped_version_sha.outputs.bumped_version_sha || github.sha }} |
90 |
| - runs-on: ubuntu-latest |
91 |
| - steps: |
92 |
| - - uses: actions/checkout@v2 |
93 |
| - - uses: actions/setup-python@v1 |
94 |
| - with: |
95 |
| - python-version: 3.7 |
96 |
| - - name: Install bump2version |
97 |
| - run: pip install bump2version |
98 |
| - - uses: oleksiyrudenko/gha-git-credentials@v2-latest |
99 |
| - with: |
100 |
| - token: ${{ secrets.GITHUB_TOKEN }} |
101 |
| - - name: Bump version |
102 |
| - run: bump2version --verbose "$VERSION_PART" |
103 |
| - - name: Push changes |
104 |
| - uses: ad-m/github-push-action@master |
105 |
| - with: |
106 |
| - tags: true |
107 |
| - branch: ${{ github.ref }} |
108 |
| - github_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} |
109 |
| - - name: Save new git commit SHA to job output |
110 |
| - id: save_bumped_version_sha |
111 |
| - run: | |
112 |
| - echo "Setting bumped_version_sha=$(git rev-parse HEAD)" |
113 |
| - echo "::set-output name=bumped_version_sha::$(git rev-parse HEAD)" |
114 |
| -
|
115 | 8 | build_sdist:
|
116 | 9 | name: Build source distribution
|
117 | 10 | runs-on: ubuntu-latest
|
118 |
| - needs: [bump_version] |
119 |
| - # always() needed to not automatically skip this job due to one of the |
120 |
| - # get_version_part_* jobs being skipped and bump_version depending on both. |
121 |
| - if: > |
122 |
| - always() && |
123 |
| - ( |
124 |
| - needs.bump_version.result == 'success' || |
125 |
| - needs.bump_version.result == 'skipped' |
126 |
| - ) |
127 | 11 | steps:
|
128 | 12 | - uses: actions/checkout@v2
|
129 |
| - with: |
130 |
| - ref: ${{ needs.bump_version.outputs.bumped_version_sha }} |
131 | 13 | - uses: actions/setup-python@v1
|
132 | 14 | with:
|
133 | 15 | python-version: 3.7
|
|
145 | 27 | name: Deploy to PyPI
|
146 | 28 | runs-on: ubuntu-latest
|
147 | 29 | needs: [build_sdist]
|
148 |
| - # always() needed to not automatically skip this job due to one of the |
149 |
| - # get_version_part_* jobs being skipped and bump_version depending on both. |
150 |
| - if: always() && needs.build_sdist.result == 'success' |
151 | 30 | steps:
|
152 | 31 | - uses: actions/checkout@v2
|
153 | 32 | - name: Download source package
|
|
0 commit comments