Skip to content

Commit 32e8279

Browse files
author
Jacob Truman
committed
Improve build steps
1 parent 7bbadd6 commit 32e8279

File tree

1 file changed

+26
-17
lines changed

1 file changed

+26
-17
lines changed

.github/workflows/build.yaml

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
test:
1212
# When running with act (https://github.com/nektos/act), these lines need to be appended with the ACT variable
1313
# to force each job to run
14-
if: github.repository == 'adobe/buildrunner' #|| ${{ env.ACT }}
14+
if: github.repository == 'adobe/buildrunner' && (github.ref != 'refs/heads/main' || github.event.pull_request.merged != true) #|| ${{ env.ACT }}
1515
runs-on: ubuntu-latest
1616
strategy:
1717
fail-fast: false
@@ -49,10 +49,12 @@ jobs:
4949
check_name: "Test Results ${{ matrix.python-version }}"
5050
github_retries: 10
5151
secondary_rate_limit_wait_seconds: 60.0
52-
tag-commit:
53-
if: github.repository == 'adobe/buildrunner' && github.event_name == 'push' && github.ref == 'refs/heads/main'
52+
get-version:
53+
if: github.repository == 'adobe/buildrunner'
5454
runs-on: ubuntu-latest
5555
needs: test
56+
outputs:
57+
current-version: ${{ steps.version-number.outputs.CURRENT_VERSION }}
5658
steps:
5759
- uses: actions/checkout@v2
5860
with:
@@ -64,12 +66,22 @@ jobs:
6466
pip install -r requirements.txt
6567
- name: Write version file
6668
run: python scripts/write-version.py
67-
- name: Get and set version in env
68-
run: echo "CURRENT_VERSION=$( python -c 'from buildrunner.version import __version__; print(__version__)' )" >> $GITHUB_ENV
69+
- name: Get current version
70+
id: version-number
71+
run: echo "CURRENT_VERSION=$( python -c 'from buildrunner.version import __version__; print(__version__)' )" >> $GITHUB_OUTPUT
6972
- name: Print current version
70-
run: echo CURRENT_VERSION ${{ env.CURRENT_VERSION }}
73+
run: echo CURRENT_VERSION ${{ steps.version-number.outputs.CURRENT_VERSION }}
74+
tag-commit:
75+
if: github.repository == 'adobe/buildrunner' && github.event_name == 'push' && github.ref == 'refs/heads/main'
76+
runs-on: ubuntu-latest
77+
needs: [test, get-version]
78+
steps:
79+
- uses: actions/checkout@v2
80+
with:
81+
# Fetch all history instead of the latest commit
82+
fetch-depth: 0
7183
- name: Tag commit
72-
run: git tag ${{ env.CURRENT_VERSION }} && git push --tags
84+
run: git tag ${{ needs.get-version.outputs.current-version }} && git push --tags
7385
publish-pypi:
7486
if: github.repository == 'adobe/buildrunner'
7587
runs-on: ubuntu-latest
@@ -83,11 +95,14 @@ jobs:
8395
uses: actions/setup-python@v2
8496
with:
8597
python-version: 3.9
98+
- name: Install dependencies
99+
run: |
100+
python -m pip install --upgrade pip
101+
pip install -r requirements.txt
102+
pip install wheel build
86103
- name: Remove version file
87104
# This is just in case something else created it, destroy it to get a fresh version
88105
run: rm -f buildrunner/version.py
89-
- name: Install wheel
90-
run: pip install wheel build
91106
- name: Write version file
92107
run: python scripts/write-version.py
93108
- name: Build
@@ -104,26 +119,20 @@ jobs:
104119
publish-docker:
105120
if: github.repository == 'adobe/buildrunner'
106121
runs-on: ubuntu-latest
107-
needs: test
122+
needs: [test, get-version]
108123
steps:
109124
- uses: actions/checkout@v2
110125
with:
111126
# Fetch all history instead of the latest commit
112127
fetch-depth: 0
113-
- name: Write version file
114-
run: python scripts/write-version.py
115-
- name: Get and set version in env
116-
run: echo "CURRENT_VERSION=$( python -c 'from buildrunner.version import __version__; print(__version__)' )" >> $GITHUB_ENV
117-
- name: Print current version
118-
run: echo CURRENT_VERSION ${{ env.CURRENT_VERSION }}
119128
- name: Docker Tags
120129
id: docker_tags
121130
uses: docker/metadata-action@v3
122131
with:
123132
images: ghcr.io/adobe/buildrunner
124133
tags: |
125134
latest
126-
${{ env.CURRENT_VERSION }}
135+
${{ needs.get-version.outputs.current-version }}
127136
- name: Set up QEMU
128137
uses: docker/setup-qemu-action@v1
129138
with:

0 commit comments

Comments
 (0)