From d2cff9d40e7bb596544a63f9b07b82eafa4d2a14 Mon Sep 17 00:00:00 2001 From: Lost Paul <70213368+LostPaul@users.noreply.github.com> Date: Wed, 8 Jan 2025 12:42:15 +0100 Subject: [PATCH] Add workflows --- .github/FUNDING.yml | 1 + .github/workflows/beta-release.yaml | 74 ++++++++++++++++++++++++++++ .github/workflows/codeql.yml | 76 +++++++++++++++++++++++++++++ .github/workflows/deploy-mkdocs.yml | 27 ++++++++++ .github/workflows/release.yaml | 57 ++++++++++++++++++++++ 5 files changed, 235 insertions(+) create mode 100644 .github/FUNDING.yml create mode 100644 .github/workflows/beta-release.yaml create mode 100644 .github/workflows/codeql.yml create mode 100644 .github/workflows/deploy-mkdocs.yml create mode 100644 .github/workflows/release.yaml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..8f5e2c3 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +ko_fi: paul305844 diff --git a/.github/workflows/beta-release.yaml b/.github/workflows/beta-release.yaml new file mode 100644 index 0000000..fbe82ba --- /dev/null +++ b/.github/workflows/beta-release.yaml @@ -0,0 +1,74 @@ +# https://github.com/SilentVoid13/Templater/blob/master/.github/workflows/release.yml + +name: Plugin-beta release +on: + push: + tags: + - "[0-9]+.[0-9]+.[0-9]+-[0-9]+-beta" + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout current branch + uses: actions/checkout@v3 + with: + # This checks out the branch that triggered the workflow + ref: ${{ github.ref }} + + - name: Fetch all branches + run: git fetch --all + + - name: Extract version from tag + id: extract_version + run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV + + - name: Strip -beta from version + run: | + VERSION=${{ env.VERSION }} + RELEASE_VERSION=${VERSION%-beta} + echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV + + # Update manifest-beta.json in main branch + - name: Checkout main branch to update manifest-beta.json + run: | + git checkout main + git pull origin main + + - name: Update manifest-beta.json in main branch + run: | + VERSION=${{ env.VERSION }} + jq --arg version "$VERSION" '.version = $version' manifest-beta.json > manifest-beta-temp.json + mv manifest-beta-temp.json manifest-beta.json + + - name: Commit and push manifest-beta.json changes in main + run: | + git config --local user.email "github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" + git add manifest-beta.json + git commit -m "Update manifest-beta.json to version $VERSION in main branch" + git push origin main + + # Switch back to the original branch that triggered the workflow + - name: Switch back to branch that triggered the workflow + run: | + git checkout ${{ github.ref_name }} + git pull origin ${{ github.ref_name }} + + - name: npm build + run: | + npm install + npm run build --if-present + + - name: Set Release Name + run: echo "RELEASE_NAME=${{ env.RELEASE_VERSION }}" >> $GITHUB_ENV + + - name: Create Plugin beta release + uses: ncipollo/release-action@v1.12.0 + with: + name: Beta release ${{ env.RELEASE_NAME }} + prerelease: true + artifacts: "main.js,manifest.json,styles.css" + token: ${{ secrets.GITHUB_TOKEN }} + tag: ${{ env.VERSION }} diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 0000000..5be27e1 --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,76 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL" + +on: + push: + branches: [ "master", pull-requests-rules ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ "master" ] + schedule: + - cron: '29 9 * * 3' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'javascript' ] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] + # Use only 'java' to analyze code written in Java, Kotlin or both + # Use only 'javascript' to analyze code written in JavaScript, TypeScript or both + # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + 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. + + # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs + # queries: security-extended,security-and-quality + + + # Autobuild attempts to build any compiled languages (C/C++, C#, Go, 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@v2 + + # â„šī¸ Command-line programs to run using the OS shell. + # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun + + # If the Autobuild fails above, remove it and uncomment the following three lines. + # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. + + # - run: | + # echo "Run, Build Application using script" + # ./location_of_script_within_repo/buildscript.sh + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 + with: + category: "/language:${{matrix.language}}" diff --git a/.github/workflows/deploy-mkdocs.yml b/.github/workflows/deploy-mkdocs.yml new file mode 100644 index 0000000..ad67a08 --- /dev/null +++ b/.github/workflows/deploy-mkdocs.yml @@ -0,0 +1,27 @@ +name: ci +on: + push: + branches: + - master + - main +permissions: + contents: write +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: 3.x + - uses: actions/cache@v2 + with: + key: ${{ github.ref }} + path: .cache + - run: pip install mkdocs-material + - run: pip install mkdocs-video + - run: pip install pillow cairosvg + - working-directory: ./docs + run: mkdocs gh-deploy --force + + diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..8dac309 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,57 @@ +# https://github.com/SilentVoid13/Templater/blob/master/.github/workflows/release.yml +name: Plugin release +on: + push: + tags: + - "[0-9]+.[0-9]+.[0-9]+" + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Extract branch name + id: extract_branch + run: echo "BRANCH_NAME=$(git branch -r --contains ${GITHUB_SHA} | grep -v 'detached' | sed 's|origin/||' | xargs)" >> $GITHUB_ENV + + # Checkout the main branch to update manifest.json + - name: Checkout main branch to update manifest + run: | + git checkout main + git pull origin main + + - name: Update manifest.json in main branch + run: | + VERSION=${GITHUB_REF#refs/tags/} + jq --arg version "$VERSION" '.version = $version' manifest.json > manifest-temp.json + mv manifest-temp.json manifest.json + + - name: Commit and push manifest.json changes in main + run: | + git config --local user.email "github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" + git add manifest.json + git commit -m "Update manifest.json to version $VERSION" + git push origin main + + # Switch back to the branch that triggered the workflow + - name: Checkout original branch + run: | + git checkout ${{ env.BRANCH_NAME }} + git pull origin ${{ env.BRANCH_NAME }} + + - name: npm build + run: | + npm install + npm run build --if-present + + - name: Create Plugin release + uses: ncipollo/release-action@v1.12.0 + with: + artifacts: "main.js,manifest.json,styles.css" + token: ${{ secrets.GITHUB_TOKEN }} + tag: ${{ github.ref_name }}