2022-07-22 15:24:11 -04:00
|
|
|
name: Release
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- master
|
|
|
|
|
|
|
|
jobs:
|
2023-04-05 18:49:48 -04:00
|
|
|
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"
|
2023-04-06 14:58:20 -04:00
|
|
|
echo "version_changed=$GOTIME" >> $GITHUB_OUTPUT
|
2023-04-05 18:49:48 -04:00
|
|
|
|
2022-07-22 15:24:11 -04:00
|
|
|
build:
|
|
|
|
runs-on: ubuntu-latest
|
2023-04-06 14:13:51 -04:00
|
|
|
# needs: [ check_for_changed_version ]
|
|
|
|
# if: needs.check_for_changed_version.outputs.version_changed == 'True'
|
2022-07-22 15:24:11 -04:00
|
|
|
permissions:
|
|
|
|
contents: write
|
|
|
|
steps:
|
2023-03-22 22:27:33 -04:00
|
|
|
- uses: https://github.com/actions/checkout@v2
|
|
|
|
- uses: https://github.com/actions/setup-python@v4
|
2022-07-22 15:28:13 -04:00
|
|
|
with:
|
2023-03-22 22:30:02 -04:00
|
|
|
python-version: '3.11.x'
|
2022-07-23 15:09:59 -04:00
|
|
|
- name: Install Env
|
|
|
|
# this should be all we need because shiv will download the deps itself
|
|
|
|
run: |
|
2022-07-23 15:26:10 -04:00
|
|
|
pip install --upgrade pip
|
2022-07-23 15:09:59 -04:00
|
|
|
pip install shiv
|
|
|
|
pip install poetry
|
2023-04-05 18:49:48 -04:00
|
|
|
- name: Add VERSION env property
|
2023-04-06 14:58:20 -04:00
|
|
|
run: |
|
|
|
|
echo "VERSION=v$(poetry version | python -c 'import sys;print(sys.stdin.read().split()[1])')" >> $GITHUB_ENV
|
|
|
|
echo ${{ env.VERSION }}
|
2022-07-23 12:05:34 -04:00
|
|
|
- name: Build the sucker
|
|
|
|
run: |
|
2023-04-05 18:49:48 -04:00
|
|
|
sed -i -e "s/?????/${{ env.VERSION }}/g" src/__init__.py
|
2022-07-23 12:05:34 -04:00
|
|
|
make build
|
2023-03-23 19:41:03 -04:00
|
|
|
- name: Create release!
|
2023-03-23 19:30:25 -04:00
|
|
|
run: |
|
2023-03-25 21:22:03 -04:00
|
|
|
JSON_DATA=$(
|
|
|
|
printf '%s' \
|
|
|
|
'{'\
|
2023-04-05 18:49:48 -04:00
|
|
|
'"tag_name":"${{ env.VERSION }}",'\
|
|
|
|
'"name":"${{ env.VERSION }}",'\
|
2023-03-25 21:22:03 -04:00
|
|
|
'"body":"RELEASE THE KRAKEN"'\
|
|
|
|
'}' \
|
|
|
|
)
|
2023-03-23 19:30:25 -04:00
|
|
|
echo """release_id=$(\
|
2023-03-25 00:21:28 -04:00
|
|
|
curl -X POST \
|
2023-04-06 14:58:20 -04:00
|
|
|
-s https://git.joekaufeld.com/api/v1/repos/${GITHUB_REPOSITORY%/*}/${{ github.event.repository.name }}/releases \
|
2023-03-23 19:30:25 -04:00
|
|
|
-H "Authorization: token ${{ secrets.PAT }}" \
|
2023-03-25 00:21:28 -04:00
|
|
|
-H 'Content-Type: application/json' \
|
2023-03-25 21:33:05 -04:00
|
|
|
-d "$JSON_DATA" \
|
2023-03-23 19:30:25 -04:00
|
|
|
| python3 -c "import sys, json; print(json.load(sys.stdin)['id'])"\
|
2023-04-06 14:30:24 -04:00
|
|
|
)""" >> $GITHUB_ENV
|
2023-03-23 19:41:03 -04:00
|
|
|
- name: Upload assets!
|
|
|
|
run: |
|
2023-04-06 14:58:20 -04:00
|
|
|
curl https://git.joekaufeld.com/api/v1/repos/${GITHUB_REPOSITORY%/*}/${{ github.event.repository.name }}/releases/${{ env.release_id }}/assets \
|
2023-03-23 19:30:25 -04:00
|
|
|
-H "Authorization: token ${{ secrets.PAT }}" \
|
2023-03-23 19:48:52 -04:00
|
|
|
-F attachment=@utils
|