From 18a4630732124a03f84d7d0fd5c561cf93c9c61d Mon Sep 17 00:00:00 2001 From: Kennedy Kori Date: Tue, 19 Mar 2024 22:28:23 +0300 Subject: [PATCH] ci: fix invalid Github workflow errors --- .github/workflows/ci.yml | 97 ++++++++++++++++++++++++++--------- .github/workflows/release.yml | 60 ---------------------- 2 files changed, 74 insertions(+), 83 deletions(-) delete mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f992f3d..84b66ea 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,35 +1,86 @@ name: CI -on: [push] +on: + - push env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} jobs: - build: + build: + permissions: + contents: read runs-on: ubuntu-latest - strategy: matrix: - python-version: ["3.10", "3.11"] - + python-version: + - "3.10" + - "3.11" steps: - - uses: actions/checkout@v3 - - name: Set up project using python ${{ matrix.python-version }} - uses: actions/setup-python@v3 - with: - python-version: ${{ matrix.python-version }} - - # Run all pre-commit hooks on all the files. - # Getting only staged files can be tricky in case a new PR is opened - # since the action is run on a branch in detached head state - - name: Install and run pre-commit - uses: pre-commit/action@v3.0.0 + - uses: actions/checkout@v4 + - name: Set up project using python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + cache: pip + python-version: ${{ matrix.python-version }} + # Run all pre-commit hooks on all the files. + # Getting only staged files can be tricky in case a new PR is opened + # since the action is run on a branch in detached head state + - name: Install and run pre-commit + uses: pre-commit/action@v3.0.1 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install tox tox-gh-actions + - name: Test with tox + run: tox -r - - name: Install dependencies - run: | - python -m pip install --upgrade pip - python -m pip install tox tox-gh-actions - - - name: Test with tox - run: tox -r + release: + # Only run on the 'main' and 'develop' branches. + if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' + needs: + - build + permissions: write-all + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + token: ${{ secrets.FYJ_GH_TOKEN }} + - name: Set up Python + uses: actions/setup-python@v5 + with: + cache: pip + python-version: "3.11" + - name: Install requirements + run: | + python -m pip install --upgrade pip + python -m pip install tox tox-gh-actions + - name: Set up GPG + uses: crazy-max/ghaction-import-gpg@v6 + with: + git_commit_gpgsign: true + git_committer_email: ${{ secrets.FYJ_GIT_COMMITTER_EMAIL }} + git_committer_name: ${{ secrets.FYJ_GIT_COMMITTER_NAME }} + # Currently, signing commits leads to the CI hanging indefinitely. + # See https://github.com/semantic-release/semantic-release/issues/3065 + git_tag_gpgsign: false + git_user_signingkey: true + gpg_private_key: ${{ secrets.FYJ_GPG_KEY }} + passphrase: ${{ secrets.FYJ_GPG_KEY_PASSPHRASE }} + trust_level: 5 + - name: Set up NodeJS + uses: actions/setup-node@v4 + with: + cache: npm + node-version-file: .nvmrc + - name: Install semantic-release + run: npm ci + - name: Create a release + env: + DEBUG: semantic-release:* + GIT_AUTHOR_EMAIL: ${{ secrets.FYJ_GIT_COMMITTER_EMAIL }} + GIT_AUTHOR_NAME: ${{ secrets.FYJ_GIT_COMMITTER_NAME }} + GIT_COMMITTER_EMAIL: ${{ secrets.FYJ_GIT_COMMITTER_EMAIL }} + GIT_COMMITTER_NAME: ${{ secrets.FYJ_GIT_COMMITTER_NAME }} + GITHUB_TOKEN: ${{ secrets.FYJ_GH_TOKEN }} + run: npx semantic-release diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index a9dcbfa..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,60 +0,0 @@ -name: CD - -on: - - push - -jobs: - release: - # Only run on the 'main' and 'develop' branches. - if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' - needs: [ build ] - permissions: write-all - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - token: ${{ secrets.FYJ_GH_TOKEN }} - - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: 3.11 - cache: pip - - - name: Install requirements - run: | - python -m pip install --upgrade pip - python -m pip install tox tox-gh-actions - - - name: Set up GPG - uses: crazy-max/ghaction-import-gpg@v6 - with: - git_commit_gpgsign: true - git_committer_email: ${{ secrets.FYJ_GIT_COMMITTER_EMAIL }} - git_committer_name: ${{ secrets.FYJ_GIT_COMMITTER_NAME }} - # Currently, signing commits leads to the CI hanging indefinitely. - # See https://github.com/semantic-release/semantic-release/issues/3065 - git_tag_gpgsign: false - git_user_signingkey: true - gpg_private_key: ${{ secrets.FYJ_GPG_KEY }} - passphrase: ${{ secrets.FYJ_GPG_KEY_PASSPHRASE }} - trust_level: 5 - - - name: Set up NodeJS - uses: actions/setup-node@v4 - with: - cache: npm - node-version-file: .nvmrc - - - name: Install semantic-release - run: npm ci - - - name: Create a release - env: - DEBUG: semantic-release:* - GIT_AUTHOR_EMAIL: ${{ secrets.FYJ_GIT_COMMITTER_EMAIL }} - GIT_AUTHOR_NAME: ${{ secrets.FYJ_GIT_COMMITTER_NAME }} - GIT_COMMITTER_EMAIL: ${{ secrets.FYJ_GIT_COMMITTER_EMAIL }} - GIT_COMMITTER_NAME: ${{ secrets.FYJ_GIT_COMMITTER_NAME }} - GITHUB_TOKEN: ${{ secrets.FYJ_GH_TOKEN }} - run: npx semantic-release