From 11df0915cc3132073d8c8c287b3eb1bffc72b5b1 Mon Sep 17 00:00:00 2001 From: Chris Butler Date: Tue, 7 Nov 2023 12:40:23 +1100 Subject: [PATCH 1/4] chore(cicd): Automate tagging process Signed-off-by: Chris Butler --- .github/workflows/tests.yml | 82 +++++++++++++++++++------------------ pyproject.toml | 4 +- 2 files changed, 45 insertions(+), 41 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 0a436b5..49397ba 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -74,50 +74,52 @@ jobs: run: | pre-commit run --config .pre-commit-test.yaml --all-files --verbose --show-diff-on-failure - # tag_version: - # needs: [pre-commit, tests, pre-commit-hook] - # if: github.ref == 'refs/heads/main' && github.repository == 'butler54/mdformat-frontmatter' + tag_github_publish: + needs: [pre-commit, tests, pre-commit-hook] + runs-on: ubuntu-latest + steps: + - name: Checkout source + uses: actions/checkout@v4 + with: + submodules: true + fetch-depth: 0 + # needs to be a GH admins + token: ${{ secrets.ADMIN_WRITE_PAT }} + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: 3.9 + - name: Install python release tools + run: pip install python-semantic-release flit + + - name: Test semantic release + run: semantic-release version --print + + - name: Release a new version to github + if: github.ref == 'refs/heads/main' && github.repository == 'butler54/mdformat-frontmatter' + env: + GH_TOKEN: ${{ secrets.ADMIN_WRITE_PAT }} + run: | + git config --global user.name "semantic-release (via Github actions)" + git config --global user.email "semantic-release@github-actions" + semantic-release publish --verbosity=DEBUG + # publish: + # name: Publish to PyPi + # if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') # runs-on: ubuntu-20.04 # steps: # - name: Checkout source # uses: actions/checkout@v3 - # with: - # submodules: true - # fetch-depth: 0 - # # needs to be a GH admins - # token: ${{ secrets.ADMIN_WRITE_PAT }} - # - name: Set up Python - # uses: actions/setup-python@v4 + # - name: Set up Python 3.9 + # uses: actions/setup-python@v1 # with: # python-version: 3.9 - # - name: Install python release tools - # run: pip install python-semantic-release flit - - # - name: Release a new version to pypi - # env: - # PYPI_TOKEN: ${{ secrets.PYPI_KEY }} - # GH_TOKEN: ${{ secrets.ADMIN_WRITE_PAT }} + # - name: install flit + # run: | + # pip install flit~=3.0 + # - name: Build and publish # run: | - # git config --global user.name "semantic-release (via Github actions)" - # git config --global user.email "semantic-release@github-actions" - # semantic-release publish --verbosity=DEBUG - # # publish: - # # name: Publish to PyPi - # # if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') - # # runs-on: ubuntu-20.04 - # # steps: - # # - name: Checkout source - # # uses: actions/checkout@v3 - # # - name: Set up Python 3.9 - # # uses: actions/setup-python@v1 - # # with: - # # python-version: 3.9 - # # - name: install flit - # # run: | - # # pip install flit~=3.0 - # # - name: Build and publish - # # run: | - # # flit publish - # # env: - # # FLIT_USERNAME: __token__ - # # FLIT_PASSWORD: ${{ secrets.PYPI_KEY }} + # flit publish + # env: + # FLIT_USERNAME: __token__ + # FLIT_PASSWORD: ${{ secrets.PYPI_KEY }} diff --git a/pyproject.toml b/pyproject.toml index 728eac9..7979e8f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -53,5 +53,7 @@ profile = "black" version_variable = [ 'mdformat_frontmatter/__init__.py:__version__' ] -build_command = 'flit build' branch = 'main' +upload_to_pypi = false +version_source = 'commit' + From af85eb539230356bbbdbfd473de6e07aa83830a7 Mon Sep 17 00:00:00 2001 From: Chris Butler Date: Tue, 7 Nov 2023 12:43:52 +1100 Subject: [PATCH 2/4] chore(lint): formating Signed-off-by: Chris Butler --- pyproject.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 7979e8f..8aa5289 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -56,4 +56,3 @@ version_variable = [ branch = 'main' upload_to_pypi = false version_source = 'commit' - From c74e82456be991fe09bd930a6317baba4183d337 Mon Sep 17 00:00:00 2001 From: Chris Butler Date: Tue, 7 Nov 2023 12:57:46 +1100 Subject: [PATCH 3/4] chore(cicd): Correct workflow so that tag publishingonly happens on a branch push Signed-off-by: Chris Butler --- .github/workflows/tests.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 49397ba..a8208da 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -76,6 +76,7 @@ jobs: tag_github_publish: needs: [pre-commit, tests, pre-commit-hook] + if: github.ref == 'refs/heads/main' && github.repository == 'butler54/mdformat-frontmatter runs-on: ubuntu-latest steps: - name: Checkout source @@ -88,15 +89,11 @@ jobs: - name: Set up Python uses: actions/setup-python@v4 with: - python-version: 3.9 + python-version: 3.11 - name: Install python release tools run: pip install python-semantic-release flit - - name: Test semantic release - run: semantic-release version --print - - name: Release a new version to github - if: github.ref == 'refs/heads/main' && github.repository == 'butler54/mdformat-frontmatter' env: GH_TOKEN: ${{ secrets.ADMIN_WRITE_PAT }} run: | From a79ba8522ff7f19813587f13aa5309f1d270444e Mon Sep 17 00:00:00 2001 From: Chris Butler Date: Tue, 7 Nov 2023 13:02:30 +1100 Subject: [PATCH 4/4] chore(cicd): workflow formatting Signed-off-by: Chris Butler --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a8208da..8e89610 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -76,7 +76,7 @@ jobs: tag_github_publish: needs: [pre-commit, tests, pre-commit-hook] - if: github.ref == 'refs/heads/main' && github.repository == 'butler54/mdformat-frontmatter + if: github.ref == 'refs/heads/main' && github.repository == 'butler54/mdformat-frontmatter' runs-on: ubuntu-latest steps: - name: Checkout source