From 96944b50ed6e8528543a168cd4e9cf1a19c4af44 Mon Sep 17 00:00:00 2001 From: John Heerman Date: Thu, 18 May 2023 08:04:25 -0500 Subject: [PATCH 1/3] Add build, publish, and release github workflows --- .github/workflows/build.yaml | 23 ++++++++++++++ .github/workflows/publish.yaml | 26 ++++++++++++++++ .github/workflows/release.yaml | 55 ++++++++++++++++++++++++++++++++++ 3 files changed, 104 insertions(+) create mode 100644 .github/workflows/build.yaml create mode 100644 .github/workflows/publish.yaml create mode 100644 .github/workflows/release.yaml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 00000000..570c935f --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,23 @@ +name: Build +on: + push: + branches: ['feature/**', 'bugfix/**'] +defaults: + run: + shell: bash +jobs: + build: + runs-on: ubuntu-latest + strategy: + fail-fast: true + steps: + - name: Set up Python 3.10 + uses: actions/setup-python@v4 + with: + python-version: "3.10" + - name: Install Dependencies + run: | + python -m pip install --upgrade pip + pip install -q flake8 tox + - name: Lint + run: tox -e flake8 diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml new file mode 100644 index 00000000..c39aa382 --- /dev/null +++ b/.github/workflows/publish.yaml @@ -0,0 +1,26 @@ +name: Publish +on: + push: + branches: ['master'] +defaults: + run: + shell: bash +jobs: + tag-trunk: + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Create Tag + id: create-tag + run: | + MAJOR_NUMBER=1 + MINOR_NUMBER=0 + REVISION_NUMBER=$(git rev-list HEAD --count) + VERSION="${MAJOR_NUMBER}.${MINOR_NUMBER}.${REVISION_NUMBER}" + TAG="v${VERSION}" + git -c user.name="github-actions[bot]" -c user.email="github-actions-bot@agcocorp.com" tag $TAG + git push origin $TAG diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 00000000..9f32eb63 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,55 @@ +name: Release +on: + push: + branches: ['release/**'] +defaults: + run: + shell: bash +jobs: + release: + runs-on: ubuntu-latest + permissions: + id-token: write + contents: write + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Create Release Notes + id: notes + run: | + current_tag=$(git tag --points-at ${{ GITHUB.SHA }} | head -1) + last_tag=$(git tag -l "*release" --sort=-v:refname | head -1) + # look for last release tag + if [ -n "$last_tag" ]; then + last_ref=$(git show-ref -s $last_tag) + logs=$(git log $last_ref..$GITHUB_SHA --pretty='- %h %s' --date=short) + else + # if the last tag is not found, check again but don't limit results to 1 item + last_tag=$(git tag -l "*release" --sort=-v:refname) + if [ -n "$last_tag" ]; then + last_ref=$(git show-ref -s $last_tag) + logs=$(git log $last_ref..$GITHUB_SHA --pretty='- %h %s' --date=short) + else + # if we still can't find a tag, then get all the commit history + logs=$(git log --pretty='- %h %s' --date=short) + fi + fi + new_tag="${current_tag}-release" + echo "$logs" > release_notes.md + echo "NEW_TAG=$new_tag" >> $GITHUB_OUTPUT + echo "RELEASE_NAME=${new_tag:1}" >> $GITHUB_OUTPUT + git -c user.name="github-actions[bot]" -c user.email="github-actions-bot@agcocorp.com" tag $new_tag + git push origin $new_tag + - name: Create Release + uses: actions/create-release@latest + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NEW_TAG: ${{ steps.notes.outputs.NEW_TAG }} + RELEASE_NAME: ${{ steps.notes.outputs.RELEASE_NAME }} + with: + tag_name: ${{ env.NEW_TAG }} + release_name: ${{ env.RELEASE_NAME }} + body_path: release_notes.md + draft: false + prerelease: false From f579e260427e77f30e9312813d3c092f47d3c299 Mon Sep 17 00:00:00 2001 From: John Heerman Date: Thu, 18 May 2023 09:44:26 -0500 Subject: [PATCH 2/3] Remove unused pytc module to pass tox inspection --- account/utils.py | 1 - 1 file changed, 1 deletion(-) diff --git a/account/utils.py b/account/utils.py index 30e7b269..fc6e419e 100644 --- a/account/utils.py +++ b/account/utils.py @@ -8,7 +8,6 @@ from django.urls import NoReverseMatch, reverse from django.utils.encoding import force_str -import pytz from account.conf import settings from .models import PasswordHistory From 85b7f549174d9ba06178de959e3f1833d7059404 Mon Sep 17 00:00:00 2001 From: John Heerman Date: Thu, 18 May 2023 10:32:20 -0500 Subject: [PATCH 3/3] Rename ci github workflow to deprecate but also add django 4 to matrix --- .github/workflows/{ci.yaml => ci.yaml.old} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename .github/workflows/{ci.yaml => ci.yaml.old} (92%) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml.old similarity index 92% rename from .github/workflows/ci.yaml rename to .github/workflows/ci.yaml.old index 64ad25bd..df835f9e 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml.old @@ -14,7 +14,7 @@ jobs: strategy: matrix: python: [3.6, 3.7, 3.8, 3.9, "3.10"] - django: [2.2.*, 3.2.*] + django: [3.2.*, 4.0.*] steps: - uses: pinax/testing@v2