From 50705233863e9237a8b75306e0d65be20eb20d06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Ram=C3=ADrez=20de=20la=20Corte?= Date: Mon, 27 Jun 2022 01:35:50 +0200 Subject: [PATCH] feat: update ci for use conventional commits, create release and publish package --- .github/workflows/conventionalpr.yml | 14 +++++++ .github/workflows/main.yml | 34 ----------------- .github/workflows/release.yml | 57 ++++++++++++++++++++++++++++ Makefile | 8 ---- 4 files changed, 71 insertions(+), 42 deletions(-) create mode 100644 .github/workflows/conventionalpr.yml delete mode 100644 .github/workflows/main.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/conventionalpr.yml b/.github/workflows/conventionalpr.yml new file mode 100644 index 0000000..fa6aa45 --- /dev/null +++ b/.github/workflows/conventionalpr.yml @@ -0,0 +1,14 @@ +name: Conventional Commit Parser +on: + pull_request: + branches: [main, master, develop] + types: [opened, reopened, edited, review_requested, synchronize] + +jobs: + conventional_commit: + name: Conventional Commits + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - uses: webiny/action-conventional-commits@v1.0.3 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index ba37d6a..0000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: Antl compilation - -on: - push: - branches: - - master - workflow_dispatch: - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 - with: - persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal access token. - fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository. - - - name: Set up Python 3.9 - uses: actions/setup-python@v1 - with: - python-version: 3.9 - - name: ANTLR prerequisites - run: | - sudo apt-get install antlr4 - pip install twine build - - name: Compile - run: make build - - name: Build and publish - env: - TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} - run: | - python3 -m build - twine upload dist/* diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..ba02ff5 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,57 @@ +name: Create Release and publish pypi package +on: + push: + tags: + - v[0-9]+.[0-9]+.* + +jobs: + released: + name: Released + if: github.ref_type == 'tag' + runs-on: ubuntu-latest + steps: + - name: Checkout git repo + uses: actions/checkout@v2 + + - name: Automated Version Bump + id: changelog + uses: Requarks/changelog-action@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + tag: ${{github.ref_name}} + writeToFile: 'false' + + - name: Get variables + id: get_variables + run: | + echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} + echo ::set-output name=IS_PRERELEASE::"${{contains(github.ref, 'dev')}}" + + - name: Publish release github + uses: softprops/action-gh-release@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + prerelease: ${{ steps.get_variables.outputs.IS_PRERELEASE }} + tag_name: ${{ steps.get_variables.outputs.VERSION }} + body: ${{ steps.changelog.outputs.changes }} + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.9' + + - name: Install dependencies and ANTLR requirements + run: | + sudo apt-get install antlr4 + pip install twine build + + - name: Compile + run: make build + + - name: Build and publish python package + env: + TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + run: | + python3 -m build + twine upload dist/* diff --git a/Makefile b/Makefile index b89ea12..5b9da5a 100644 --- a/Makefile +++ b/Makefile @@ -3,11 +3,3 @@ .PHONY: build build: antlr4 -Dlanguage=Python3 uvlparser/UVL.g4 - -upload-testpypi: - python3 -m build - python3 -m twine upload --repository testpypi dist/* - -upload-pypi: - python3 -m build - python3 -m twine upload --repository pypi dist/*