Skip to content

Commit

Permalink
Update workflows; add logic for release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
jefflester committed Dec 4, 2023
1 parent 056d590 commit e877f4f
Show file tree
Hide file tree
Showing 6 changed files with 151 additions and 125 deletions.
41 changes: 0 additions & 41 deletions .github/workflows/branch-release.yml

This file was deleted.

32 changes: 14 additions & 18 deletions .github/workflows/cli-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,17 @@ jobs:
cli-tests:
runs-on: ubuntu-22.04
steps:

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Check out code
uses: actions/checkout@v4

- name: Install project dependencies
run: |-
pip install --editable ./src/cli/
pip install --editable ./src/test/
- name: Run CLI tests
run: |-
minitrino --help || exit 1
python ./src/test/src/cli/runner.py
- name: Check out code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install project dependencies
run: |-
pip install --editable ./src/cli/
pip install --editable ./src/test/
- name: Run CLI tests
run: |-
minitrino --help || exit 1
python ./src/test/src/cli/runner.py
49 changes: 22 additions & 27 deletions .github/workflows/lib-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,26 @@ jobs:
lib-tests:
runs-on: ubuntu-22.04
steps:

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Check out code
uses: actions/checkout@v4

- name: Install project dependencies
run: |-
pip install --editable ./src/cli/
pip install --editable ./src/test/
- name: Write config file and point to license
run: |-
echo "${LIC_DATA}" > ~/starburstdata.license
mkdir ~/.minitrino/
cat <<EOF > ~/.minitrino/minitrino.cfg
[config]
LIC_PATH=~/starburstdata.license
EOF
env:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install project dependencies
run: |-
pip install --editable ./src/cli/
pip install --editable ./src/test/
- name: Write config file and point to license
env:
LIC_DATA: ${{ secrets.LIC_DATA }}

- name: Run library tests
run: |-
python ./src/test/src/lib/runner.py
run: |-
echo "${LIC_DATA}" > ~/starburstdata.license
mkdir ~/.minitrino/
cat <<EOF > ~/.minitrino/minitrino.cfg
[config]
LIC_PATH=~/starburstdata.license
EOF
- name: Run library tests
run: |-
python ./src/test/src/lib/runner.py
80 changes: 80 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: Publish Release on Merge to Master

on:
pull_request:
types:
- closed

jobs:
publish-release-draft:
runs-on: ubuntu-22.04
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Create release
env:
GITHUB_TOKEN: ${{ secrets.MINITRINO_TOKEN }}
run: |-
RELEASE_NOTES=./release-notes/"${GITHUB_HEAD_REF}".md
DESCRIPTION=$(cat "${RELEASE_NOTES}")
if [ ! -f "${RELEASE_NOTES}" ]; then
echo "Release notes file not found at ${RELEASE_NOTES}. Exiting..."
exit 1
fi
echo "Checking if release exists..."
if gh release list | grep -q -e "${GITHUB_HEAD_REF}"; then
echo "Release ${GITHUB_HEAD_REF} found. Deleting release..."
gh release delete "${GITHUB_HEAD_REF}" -y --cleanup-tag
fi
echo "Creating release from branch ${GITHUB_HEAD_REF}..."
gh release create "${GITHUB_HEAD_REF}" \
--prerelease \
--draft=true \
--title "${GITHUB_HEAD_REF}" \
--notes "${DESCRIPTION}" \
--target "${GITHUB_HEAD_REF}"
publish-release:
runs-on: ubuntu-22.04
needs: publish-release-draft
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Publish release
env:
GITHUB_TOKEN: ${{ secrets.MINITRINO_TOKEN }}
run: |-
gh release edit "${GITHUB_HEAD_REF}" \
--prerelease=false \
--draft=false \
--latest
pypi-publish:
runs-on: ubuntu-22.04
needs: publish-release
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
run: |-
pip install wheel twine
- name: Build and check distribution
run: |-
cd src/cli
python setup.py sdist bdist_wheel
twine check dist/*
- name: Publish distribution to PyPi
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: twine upload src/cli/dist/*
- name: Check package
run: |-
pip uninstall -y minitrino
pip install minitrino==${GITHUB_HEAD_REF}
minitrino --help || exit 1
8 changes: 3 additions & 5 deletions .github/workflows/test-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ on:

jobs:
set-test-release-and-tag:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:

- name: Check out code
uses: actions/checkout@v4

- name: Delete and recreate release
env:
GITHUB_TOKEN: ${{ secrets.MINITRINO_TOKEN }}
run: |-
TAG="0.0.0"
DESCRIPTION="Used as a placeholder to give test builds access to the PR branch's module library."
Expand All @@ -33,5 +33,3 @@ jobs:
--title "${TAG}" \
--notes "${DESCRIPTION}" \
--target "${GITHUB_HEAD_REF}"
env:
GITHUB_TOKEN: ${{ secrets.MINITRINO_TOKEN }}
66 changes: 32 additions & 34 deletions .github/workflows/update-version-files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,37 @@ on:

jobs:
update-versions:
runs-on: ubuntu-latest

runs-on: ubuntu-22.04
steps:
- name: Check out code
uses: actions/checkout@v4

- name: Update version files
run: |-
BRANCH=$(echo "${GITHUB_REF#refs/heads/}")
if [[ "$GITHUB_REF" == "$BRANCH" ]]; then
echo "This workflow can only be triggered by a branch"
exit 0
fi
echo "Updating version files to version ${BRANCH}"
echo "Update ./src/lib/version"
echo "${BRANCH}" > ./src/lib/version
echo "Update ./src/cli/setup.py"
sed -i "s|version=\"[0-9]\.[0-9]\.[0-9]\"|version=\"${BRANCH}\"|" ./src/cli/setup.py
- name: Check out code
uses: actions/checkout@v4
- name: Update version files
env:
GITHUB_TOKEN: ${{ secrets.MINITRINO_TOKEN }}
run: |-
BRANCH=$(echo "${GITHUB_REF#refs/heads/}")
if [[ "$GITHUB_REF" == "$BRANCH" ]]; then
echo "This workflow can only be triggered by a branch"
exit 0
fi
echo "Updating version files to version ${BRANCH}"
echo "Update ./src/lib/version"
echo "${BRANCH}" > ./src/lib/version
echo "Update ./src/cli/setup.py"
sed -i "s|version=\"[0-9]\.[0-9]\.[0-9]\"|version=\"${BRANCH}\"|" ./src/cli/setup.py
echo "Update ./readme.md"
sed -i "s|\*\*Latest Stable Release\*\*: [0-9]\.[0-9]\.[0-9]|\*\*Latest Stable Release\*\*: ${BRANCH}|" ./readme.md
if [[ -n $(git status --porcelain) ]]; then
echo "Commit version changes"
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git config --global user.name "${GITHUB_ACTOR}"
git add ./src/lib/version ./src/cli/setup.py ./readme.md
git commit -m "Update version files to ${BRANCH}"
git push
else
echo "No version changes to commit"
fi
env:
GITHUB_TOKEN: ${{ secrets.MINITRINO_TOKEN }}
echo "Update ./readme.md"
sed -i "s|\*\*Latest Stable Release\*\*: [0-9]\.[0-9]\.[0-9]|\*\*Latest Stable Release\*\*: ${BRANCH}|" ./readme.md
if [[ -n $(git status --porcelain) ]]; then
echo "Commit version changes"
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git config --global user.name "${GITHUB_ACTOR}"
git add ./src/lib/version ./src/cli/setup.py ./readme.md
git commit -m "Update version files to ${BRANCH}"
git push
else
echo "No version changes to commit"
fi

0 comments on commit e877f4f

Please sign in to comment.