Skip to content

Commit

Permalink
feat: Configure and optimize release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobdonenfeld committed Oct 31, 2022
1 parent f2d0d17 commit 86198d1
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 111 deletions.
5 changes: 4 additions & 1 deletion .github/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ categories:
- 'bug'

- title: '🧰 Maintenance'
label: 'chore'
label: 'patch'

version-resolver:
major:
Expand All @@ -43,6 +43,7 @@ autolabeler:
- '/fix/i'
branch:
- '/fix\/.+/'
- '/bug\/.+/'
- label: 'enhancement'
branch:
- '/feature\/.+/'
Expand All @@ -52,5 +53,7 @@ autolabeler:
- label: 'patch'
branch:
- '/patch\/.+/'
- '/refactor\/.+/'
title:
- '/patch/i'
- '/refactor/i'
18 changes: 18 additions & 0 deletions .github/scripts/set_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"""Update the version file."""
import os
import sys


def update_manifest():
"""Update the manifest file."""
version = "0.0.0"
for index, value in enumerate(sys.argv):
if value in ["--version", "-V"]:
version = sys.argv[index + 1]

with open(f"{os.getcwd()}/pre_commit_hooks/VERSION", "w") as version_file:
version_file.write(version)
version_file.close()


update_manifest()
26 changes: 0 additions & 26 deletions .github/scripts/update_version.py

This file was deleted.

38 changes: 0 additions & 38 deletions .github/workflows/publish-to-pypi.yml

This file was deleted.

44 changes: 0 additions & 44 deletions .github/workflows/publish-to-test-pypi.yml

This file was deleted.

35 changes: 33 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ jobs:
steps:
- name: Check out repository
uses: actions/checkout@v2
- name: "Set manifest version number"
- name: "Set version number"
run: |
python3 ${{ github.workspace }}/.github/scripts/update_manifest.py
python3 ${{ github.workspace }}/.github/scripts/set_version.py --version ${{ github.event.release.tag_name }}
- name: Create zip
run: |
zip gitlab-hooks.zip -r ./
Expand All @@ -25,3 +25,34 @@ jobs:
asset_name: gitlab-hooks.zip
tag: ${{ github.ref }}
overwrite: true
build-and-publish:
name: Build and publish Python PyPI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"
- name: "Set version number"
run: |
python3 ${{ github.workspace }}/.github/scripts/set_version.py --version ${{ github.event.release.tag_name }}
- name: Install pypa/build
run: >-
python -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
run: >-
python -m
build
--sdist
--wheel
--outdir dist/
.
- name: Publish distribution 📦 to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
1 change: 1 addition & 0 deletions pre_commit_hooks/gitlab_script_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def main(argv=None): # pylint: disable=inconsistent-return-statements

def call_ci_script_check(args=None):
"""
Heft of the file. Takes in arguments, returns whether it has an error or not in the scripts.
"""
fail = False
Expand Down
1 change: 1 addition & 0 deletions tests/gitlab_linter_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
)
def test_yml_files(test_file_path, expected):
"""
Test sending yml files to gitlab ci lint api
"""
assert (
Expand Down

0 comments on commit 86198d1

Please sign in to comment.