adjust workflow to only run if version changes
This commit is contained in:
parent
cf61dcf705
commit
c9dc7fb270
35
.github/workflows/build_and_release.yml
vendored
35
.github/workflows/build_and_release.yml
vendored
@ -6,8 +6,33 @@ on:
|
|||||||
- master
|
- master
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
check_for_changed_version:
|
||||||
|
runs-on: 'ubuntu-latest'
|
||||||
|
# Declare outputs for next jobs
|
||||||
|
outputs:
|
||||||
|
version_changed: ${{ steps.check_file_changed.outputs.version_changed }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
# Checkout as many commits as needed for the diff
|
||||||
|
fetch-depth: 2
|
||||||
|
- id: check_file_changed
|
||||||
|
run: |
|
||||||
|
# Diff HEAD with the previous commit
|
||||||
|
if git diff HEAD^ HEAD pyproject.toml | grep -q "+version =";
|
||||||
|
then
|
||||||
|
GOTIME="True"
|
||||||
|
else
|
||||||
|
GOTIME="False"
|
||||||
|
fi
|
||||||
|
echo "::notice title=GOTIME::$GOTIME"
|
||||||
|
# Set the output named "version_changed"
|
||||||
|
echo "version_changed=$GOTIME" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
needs: [ check_for_changed_version ]
|
||||||
|
if: needs.check_for_changed_version.outputs.version_changed == 'True'
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
steps:
|
steps:
|
||||||
@ -21,19 +46,19 @@ jobs:
|
|||||||
pip install --upgrade pip
|
pip install --upgrade pip
|
||||||
pip install shiv
|
pip install shiv
|
||||||
pip install poetry
|
pip install poetry
|
||||||
- name: Add CURRENT_TIME env property
|
- name: Add VERSION env property
|
||||||
run: echo "CURRENT_TIME_VERSION=v$(date '+%s')" >> $GITHUB_ENV
|
run: echo "VERSION=v$(poetry version | python -c 'import sys;print(sys.stdin.read().split()[1])')" >> $GITHUB_ENV
|
||||||
- name: Build the sucker
|
- name: Build the sucker
|
||||||
run: |
|
run: |
|
||||||
sed -i -e "s/?????/${{ env.CURRENT_TIME_VERSION }}/g" src/__init__.py
|
sed -i -e "s/?????/${{ env.VERSION }}/g" src/__init__.py
|
||||||
make build
|
make build
|
||||||
- name: Create release!
|
- name: Create release!
|
||||||
run: |
|
run: |
|
||||||
JSON_DATA=$(
|
JSON_DATA=$(
|
||||||
printf '%s' \
|
printf '%s' \
|
||||||
'{'\
|
'{'\
|
||||||
'"tag_name":"${{ env.CURRENT_TIME_VERSION }}",'\
|
'"tag_name":"${{ env.VERSION }}",'\
|
||||||
'"name":"${{ env.CURRENT_TIME_VERSION }}",'\
|
'"name":"${{ env.VERSION }}",'\
|
||||||
'"body":"RELEASE THE KRAKEN"'\
|
'"body":"RELEASE THE KRAKEN"'\
|
||||||
'}' \
|
'}' \
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user