Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use GitHub action to automatically create tag based on __version__ #3

Merged
merged 1 commit into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/workflows/on-new-tag.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: on_new_tag

on:
push:
tags:
- '*'

jobs:
check_ver:
runs-on: ubuntu-22.04
strategy:
matrix:
python-version: [ 3.11 ]

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Installing Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Check tag matches version
run: |
[[ $(python3 -m GradescopeGrader version) == ${GITHUB_REF#refs/tags/v} ]]

67 changes: 67 additions & 0 deletions .github/workflows/test-and-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: test_and_release


on:
push:
branches: [ main ]
pull_request:
branches: [ main ]


jobs:
test_and_release:
name: Unit Testing and then Release

strategy:
matrix:
os: [ ubuntu-22.04 ]
python-version: [ 3.11 ]

runs-on: ${{ matrix.os }}

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Installing Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Run Unit Testing
working-directory: ${{ github.workspace }}
run: |
python3 runtests.py

- name: Test setup.py
working-directory: ${{ github.workspace }}
run: |
python3 -m pip install ${{ github.workspace }}

- name: Installing GitHubApiHelper
run: |
python3 -m pip install git+https://github.com/zhenghaven/[email protected]

- name: Get latest version
id: latest_ver
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
python3 -m GitHubApiHelper --auth-token \
api_tags_latest_ver \
--repo ${{ github.repository }} \
-l $(python3 -m GradescopeGrader version) \
--github-out

- name: Create tag
if: ${{ startsWith(github.ref, 'refs/heads/main') && steps.latest_ver.outputs.remote != steps.latest_ver.outputs.all }}
uses: actions/github-script@v6
with:
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'refs/tags/${{ steps.latest_ver.outputs.allV }}',
sha: context.sha
})

39 changes: 0 additions & 39 deletions .github/workflows/unittesting.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion GradescopeGrader/_Meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@



__version__ = '0.1.0'
__version__ = '0.1.2'

PKG_AUTHOR = 'Haofan Zheng'
PKG_NAME = 'GradescopeGrader'
Expand Down
10 changes: 10 additions & 0 deletions GradescopeGrader/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ def main():
help='operation to perform',
required=True,
)
opParser.add_parser(
'version',
help='print version and exit',
)

args = argParser.parse_args()

Expand All @@ -36,6 +40,12 @@ def main():
format='%(asctime)s %(name)s[%(levelname)s]: %(message)s',
)

if args.operation == 'version':
from ._Meta import __version__
print(__version__)
else:
raise NotImplementedError('unknown operation {}'.format(args.operation))


if __name__ == '__main__':
main()