forked from pinax/django-user-accounts
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from jheerman/feature/add-github-workflows
Add build, publish, and release github workflows
- Loading branch information
Showing
5 changed files
with
105 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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="[email protected]" tag $TAG | ||
git push origin $TAG |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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="[email protected]" 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters