From 7bd7407993ea14de89483435a872f8e70f067a2e Mon Sep 17 00:00:00 2001 From: Aidan Timson Date: Mon, 1 Apr 2024 11:54:14 +0100 Subject: [PATCH] Update workflows --- .github/workflows/build.yml | 22 ++++ .github/workflows/codeql-analysis.yml | 67 ------------ .github/workflows/codeql.yml | 27 +++++ .github/workflows/dependabot-automerge.yml | 14 +++ .github/workflows/dependency-review.yml | 13 +++ .github/workflows/deploy.yml | 115 ++++++++++++++++++--- .github/workflows/labels.yml | 15 +-- .github/workflows/lint.yml | 38 +++++++ .github/workflows/lock.yml | 21 ---- .github/workflows/release-drafter.yml | 13 +-- .github/workflows/stale.yml | 40 ------- .github/workflows/test.yml | 26 +++++ 12 files changed, 247 insertions(+), 164 deletions(-) create mode 100644 .github/workflows/build.yml delete mode 100644 .github/workflows/codeql-analysis.yml create mode 100644 .github/workflows/codeql.yml create mode 100644 .github/workflows/dependabot-automerge.yml create mode 100644 .github/workflows/dependency-review.yml create mode 100644 .github/workflows/lint.yml delete mode 100644 .github/workflows/lock.yml delete mode 100644 .github/workflows/stale.yml create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..87728d9 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,22 @@ +--- +name: "Build" + +# yamllint disable-line rule:truthy +on: + push: + branches: + - master + pull_request: + types: + - opened + - reopened + - synchronize + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} + cancel-in-progress: true + +jobs: + build: + uses: timmo001/workflows/.github/workflows/build-python-linux.yml@master diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml deleted file mode 100644 index 30e5850..0000000 --- a/.github/workflows/codeql-analysis.yml +++ /dev/null @@ -1,67 +0,0 @@ -name: "CodeQL" - -# yamllint disable-line rule:truthy -on: - push: - branches: [master] - pull_request: - # The branches below must be a subset of the branches above - branches: [master] - schedule: - - cron: "0 12 * * 4" - -jobs: - analyze: - name: Analyze - runs-on: ubuntu-latest - - strategy: - fail-fast: false - matrix: - # Override automatic language detection by changing the below list - # Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python'] - language: ["python"] - # Learn more... - # https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - with: - # We must fetch at least the immediate parents so that if this is - # a pull request then we can checkout the head. - fetch-depth: 2 - - # If this run was triggered by a pull request event, then checkout - # the head of the pull request instead of the merge commit. - - run: git checkout HEAD^2 - if: ${{ github.event_name == 'pull_request' }} - - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v3 - with: - languages: ${{ matrix.language }} - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. - # queries: ./path/to/local/query, your-org/your-repo/queries@main - - # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v3 - - # โ„น๏ธ Command-line programs to run using the OS shell. - # ๐Ÿ“š https://git.io/JvXDl - - # โœ๏ธ If the Autobuild fails above, remove it and uncomment the following three lines - # and modify them (or add more) to build your code if your project - # uses a compiled language - - #- run: | - # make bootstrap - # make release - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v3 diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 0000000..279bd8d --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,27 @@ +--- +name: "CodeQL" + +# yamllint disable-line rule:truthy +on: + push: + branches: + - master + pull_request: + branches: + - master + schedule: + - cron: "0 12 * * 4" + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} + cancel-in-progress: true + +permissions: + actions: read + contents: read + security-events: write + +jobs: + codeql-analyze-python: + uses: timmo001/workflows/.github/workflows/codeql-python.yml@master diff --git a/.github/workflows/dependabot-automerge.yml b/.github/workflows/dependabot-automerge.yml new file mode 100644 index 0000000..715f7f3 --- /dev/null +++ b/.github/workflows/dependabot-automerge.yml @@ -0,0 +1,14 @@ +--- +name: "Dependabot - Auto-merge" + +# yamllint disable-line rule:truthy +on: + pull_request_target: + +permissions: + pull-requests: write + contents: write + +jobs: + dependabot-automerge: + uses: timmo001/workflows/.github/workflows/dependabot-automerge-any.yml@master diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml new file mode 100644 index 0000000..6541712 --- /dev/null +++ b/.github/workflows/dependency-review.yml @@ -0,0 +1,13 @@ +--- +name: "Dependency Review" + +# yamllint disable-line rule:truthy +on: + - pull_request + +permissions: + contents: read + +jobs: + dependency-review: + uses: timmo001/workflows/.github/workflows/depedency-review.yml@master diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index ce124f0..3b43594 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,35 +1,116 @@ --- -name: Deploy +name: "Deploy" # yamllint disable-line rule:truthy on: release: types: - published - workflow_run: - workflows: ["CI"] - branches: [master] - types: - - completed + workflow_dispatch: + +env: + MODULE_NAME: aiolyric jobs: deploy: + name: ๐Ÿš€ Linux - Deploy Module runs-on: ubuntu-latest - if: startsWith(github.ref, 'refs/tags/') + permissions: + id-token: write steps: - - uses: actions/checkout@v4 - - name: Set up Python + - name: โคต๏ธ Check out code from GitHub + uses: actions/checkout@v4.1.2 + with: + ref: "master" + token: ${{ secrets.PUSH_TOKEN }} + - name: ๐Ÿ— Set up Python uses: actions/setup-python@v5.1.0 with: - python-version: "3.x" - - name: Install dependencies + python-version: "3.12" + architecture: "x64" + cache: "pip" + - name: ๐Ÿ— Install setuptools, wheel, twine, click, twisted, incremental + run: | + python -m pip install --upgrade setuptools wheel twine click twisted incremental + - name: ๐Ÿ”ข Get old version + id: get-version-old + run: | + python -m pip install . + + # Read version from _version.py + result=$(python <> $GITHUB_OUTPUT + - name: ๐Ÿ”ข Set correct vertion - Developement + if: ${{ github.event_name != 'release' }} + run: | + # If version does not contain dev, add it + if [[ ! "${{ steps.get-version-old.outputs.version }}" == *"dev"* ]]; then + python -m incremental.update ${{ env.MODULE_NAME }} --dev + fi + - name: ๐Ÿ”ข Set correct vertion - Release + if: ${{ github.event_name == 'release' }} + run: | + # If version contains dev*, remove it + if [[ "${{ steps.get-version-old.outputs.version }}" == *"dev"* ]]; then + NEW_VERSION=$(echo "${{ steps.get-version-old.outputs.version }}" | sed 's/.dev.*//') + python -m incremental.update ${{ env.MODULE_NAME }} --newversion $NEW_VERSION + fi + - name: ๐Ÿ”ข Get current version + id: get-version-current run: | - python -m pip install --upgrade pip - pip install setuptools wheel twine - - name: Build and publish + result=$(python <> $GITHUB_OUTPUT + - name: โคต๏ธ Pull latest changes from GitHub + run: | + git pull --ff + - name: ๐Ÿ–Š Commit + uses: stefanzweifel/git-auto-commit-action@v5.0.0 env: - TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + GITHUB_TOKEN: ${{ secrets.PUSH_TOKEN }} + with: + commit_message: | + Bump ${{ env.MODULE_NAME }} version to ${{ steps.get-version-current.outputs.version }} + - name: ๐Ÿ— Install package run: | python setup.py sdist bdist_wheel - twine upload dist/* + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + verbose: true + - name: ๐Ÿ”ข Increment version - Developement + if: ${{ github.event_name != 'release' }} + run: | + python -m incremental.update ${{ env.MODULE_NAME }} --dev + - name: ๐Ÿ”ข Increment version - Release + if: ${{ github.event_name == 'release' }} + run: | + python -m incremental.update ${{ env.MODULE_NAME }} --patch + python -m incremental.update ${{ env.MODULE_NAME }} --dev + - name: ๐Ÿ”ข Get new version + id: get-version-new + run: | + result=$(python <> $GITHUB_OUTPUT + - name: โคต๏ธ Pull latest changes from GitHub + run: | + git pull --ff + - name: ๐Ÿ–Š Commit + uses: stefanzweifel/git-auto-commit-action@v5.0.0 + env: + GITHUB_TOKEN: ${{ secrets.PUSH_TOKEN }} + with: + commit_message: | + Bump ${{ env.MODULE_NAME }} version to ${{ steps.get-version-new.outputs.version }} diff --git a/.github/workflows/labels.yml b/.github/workflows/labels.yml index 1689057..45b4621 100644 --- a/.github/workflows/labels.yml +++ b/.github/workflows/labels.yml @@ -1,5 +1,5 @@ --- -name: Sync labels +name: "Sync labels" # yamllint disable-line rule:truthy on: @@ -8,15 +8,10 @@ on: - master paths: - .github/labels.yml + schedule: + - cron: "34 5 * * *" + workflow_dispatch: jobs: labels: - name: โ™ป๏ธ Sync labels - runs-on: ubuntu-latest - steps: - - name: โคต๏ธ Check out code from GitHub - uses: actions/checkout@v4 - - name: ๐Ÿš€ Run Label Syncer - uses: micnncim/action-label-syncer@v1.3.0 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + uses: timmo001/workflows/.github/workflows/labels.yml@master diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..e650033 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,38 @@ +--- +name: "Lint" + +# yamllint disable-line rule:truthy +on: + push: + branches: + - master + pull_request: + types: + - opened + - reopened + - synchronize + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} + cancel-in-progress: true + +jobs: + lint-jsonlint: + uses: timmo001/workflows/.github/workflows/lint-jsonlint.yml@master + lint-markdown-links: + uses: timmo001/workflows/.github/workflows/lint-markdown-links.yml@master + lint-markdownlint: + uses: timmo001/workflows/.github/workflows/lint-markdownlint.yml@master + lint-prettier: + uses: timmo001/workflows/.github/workflows/lint-prettier.yml@master + with: + file-types: "{json,yml,yaml}" + lint-pylint: + uses: timmo001/workflows/.github/workflows/lint-pylint.yml@master + with: + module-name: aiolyric + lint-ruff: + uses: timmo001/workflows/.github/workflows/lint-ruff.yml@master + lint-yamllint: + uses: timmo001/workflows/.github/workflows/lint-yamllint.yml@master diff --git a/.github/workflows/lock.yml b/.github/workflows/lock.yml deleted file mode 100644 index f5783ce..0000000 --- a/.github/workflows/lock.yml +++ /dev/null @@ -1,21 +0,0 @@ ---- -name: Lock - -# yamllint disable-line rule:truthy -on: - schedule: - - cron: "0 9 * * *" - workflow_dispatch: - -jobs: - lock: - name: ๐Ÿ”’ Lock closed issues and PRs - runs-on: ubuntu-latest - steps: - - uses: dessant/lock-threads@v5 - with: - github-token: ${{ github.token }} - issue-lock-inactive-days: "30" - issue-lock-reason: "" - pr-lock-inactive-days: "1" - pr-lock-reason: "" diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index 736af38..63096d2 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -1,18 +1,13 @@ --- -name: Release Drafter +name: "Release Drafter" # yamllint disable-line rule:truthy on: push: branches: - master + workflow_dispatch: jobs: - update_release_draft: - name: โœ๏ธ Draft release - runs-on: ubuntu-latest - steps: - - name: ๐Ÿš€ Run Release Drafter - uses: release-drafter/release-drafter@v5.24.0 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + release-drafter: + uses: timmo001/workflows/.github/workflows/release-drafter.yml@master diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml deleted file mode 100644 index d0f3705..0000000 --- a/.github/workflows/stale.yml +++ /dev/null @@ -1,40 +0,0 @@ ---- -name: Stale - -# yamllint disable-line rule:truthy -on: - schedule: - - cron: "0 8 * * *" - workflow_dispatch: - -jobs: - stale: - name: ๐Ÿงน Clean up stale issues and PRs - runs-on: ubuntu-latest - steps: - - name: ๐Ÿš€ Run stale - uses: actions/stale@v9 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - days-before-stale: 30 - days-before-close: 7 - remove-stale-when-updated: true - stale-issue-label: "stale" - exempt-issue-labels: "no-stale,help-wanted" - stale-issue-message: > - There hasn't been any activity on this issue recently, so we - clean up some of the older and inactive issues. - - Please make sure to update to the latest version and - check if that solves the issue. Let us know if that works for you - by leaving a comment ๐Ÿ‘ - - This issue has now been marked as stale and will be closed if no - further activity occurs. Thanks! - stale-pr-label: "stale" - exempt-pr-labels: "no-stale" - stale-pr-message: > - There hasn't been any activity on this pull request recently. This - pull request has been automatically marked as stale because of that - and will be closed if no further activity occurs within 7 days. - Thank you for your contributions. diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..b61b32c --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,26 @@ +--- +name: "Test" + +# yamllint disable-line rule:truthy +on: + push: + branches: + - master + pull_request: + types: + - opened + - reopened + - synchronize + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} + cancel-in-progress: true + +jobs: + test: + uses: timmo001/workflows/.github/workflows/test-pytest.yml@master + secrets: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + with: + module-name: "aiolyric"