From 5a88b609c4f535acbd1b19b4babcd8a4368ebfdf Mon Sep 17 00:00:00 2001 From: Garulf <535299+Garulf@users.noreply.github.com> Date: Thu, 13 Jan 2022 10:40:40 -0500 Subject: [PATCH] Update workflows --- .github/workflows/bump.yml | 41 ----------- .github/workflows/dev-builder.yml | 54 -------------- .github/workflows/pr-packager.yml | 47 ++++++++++++ .../{release-builder.yml => release.yml} | 43 ++++++----- .github/workflows/test.yml | 71 +++++++++++++++++++ 5 files changed, 138 insertions(+), 118 deletions(-) delete mode 100644 .github/workflows/bump.yml delete mode 100644 .github/workflows/dev-builder.yml create mode 100644 .github/workflows/pr-packager.yml rename .github/workflows/{release-builder.yml => release.yml} (54%) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/bump.yml b/.github/workflows/bump.yml deleted file mode 100644 index 977792b..0000000 --- a/.github/workflows/bump.yml +++ /dev/null @@ -1,41 +0,0 @@ -name: Bump Manifest Version -on: - release: - types: [published] -jobs: - release: - name: Bump file - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Get release version - run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV - - name: Get current version in file - id: version - uses: notiz-dev/github-action-json-property@release - with: - path: 'plugin.json' - prop_path: 'Version' - - run: echo ${{steps.version.outputs.prop}} - - name: "Update plugin.json version to: ${{ env.VERSION }}" - if: ${{ steps.version.outputs.prop }} != ${{ env.VERSION }} - uses: jossef/action-set-json-field@v1 - with: - file: plugin.json - field: Version - value: ${{ env.VERSION }} - - name: Commit version change - if: ${{ steps.version.outputs.prop }} != ${{ env.VERSION }} - run: | - git config user.email "41898282+github-actions[bot]@users.noreply.github.com" - git config user.name "github-actions[bot]" - git add ./plugin.json - git commit -m "Match release version: ${{ env.VERSION }}" - - name: Push changes - if: ${{ steps.version.outputs.prop }} != ${{ env.VERSION }} - uses: ad-m/github-push-action@v0.6.0 - continue-on-error: true - with: - branch: main - github_token: ${{ github.token }} diff --git a/.github/workflows/dev-builder.yml b/.github/workflows/dev-builder.yml deleted file mode 100644 index 262024c..0000000 --- a/.github/workflows/dev-builder.yml +++ /dev/null @@ -1,54 +0,0 @@ -name: "Dev-Builder" -on: - workflow_dispatch: -jobs: - deps: - name: "Build" - runs-on: windows-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - name: Set up Python ${{ env.PYTHON_VER }} - uses: actions/setup-python@v2 - with: - python-version: 3.8 - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install wheel - pip install -r ./requirements.txt -t ./lib - - name: Determine versioning - id: version - uses: paulhatch/semantic-version@v4.0.1 - with: - tag_prefix: "v" - major_pattern: "(MAJOR)" - minor_pattern: "(MINOR)" - format: "${major}.${minor}.${patch}" - short_tags: false - bump_each_commit: true - - name: "Update plugin.json version to: ${{steps.version.outputs.prop}}" - uses: jossef/action-set-json-field@v1 - with: - file: 'plugin.json' - field: Version - value: "${{steps.version.outputs.major}}.${{steps.version.outputs.minor}}.${{steps.version.outputs.patch}}" - - name: Package files - run: | - git clone https://github.com/Garulf/flow_commands/ bin - pip install -r ./bin/requirements.txt - python ./bin/commands.py package -n "${{github.event.repository.name}}.zip" - - name: Delete previous drafts - uses: Garulf/delete-draft-releases@v0.2.0 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Publish - uses: softprops/action-gh-release@v1 - with: - prerelease: true - files: "./${{github.event.repository.name}}.zip" - tag_name: "v${{steps.version.outputs.version}}" - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/pr-packager.yml b/.github/workflows/pr-packager.yml new file mode 100644 index 0000000..a66e303 --- /dev/null +++ b/.github/workflows/pr-packager.yml @@ -0,0 +1,47 @@ +name: "PR-Packager" +on: + workflow_dispatch: + pull_request: +env: + PYTHON_VER: 3.8 +jobs: + deps: + name: "Build" + runs-on: windows-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Set up Python ${{ env.PYTHON_VER }} + uses: actions/setup-python@v2 + with: + python-version: ${{ env.PYTHON_VER }} + - uses: actions/cache@v2 + if: startsWith(runner.os, 'Windows') + with: + path: ~\AppData\Local\pip\Cache + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pip- + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install wheel + pip install -r ./requirements.txt -t ./lib + - name: Get Plugin's version + id: version + uses: notiz-dev/github-action-json-property@release + with: + path: 'plugin.json' + prop_path: 'Version' + - name: Package files + run: | + git clone https://github.com/Garulf/flow_commands/ bin + pip install -r ./bin/requirements.txt + python ./bin/commands.py package -n "${{github.event.repository.name}}.zip" + - name: Upload + uses: actions/upload-artifact@v2 + with: + name: artifact + path: "./${{github.event.repository.name}}.zip" diff --git a/.github/workflows/release-builder.yml b/.github/workflows/release.yml similarity index 54% rename from .github/workflows/release-builder.yml rename to .github/workflows/release.yml index a1b47ec..9904519 100644 --- a/.github/workflows/release-builder.yml +++ b/.github/workflows/release.yml @@ -9,6 +9,8 @@ on: - .github/workflows/* - README.md - assets/* +env: + PYTHON_VER: 3.8 jobs: deps: if: ${{ github.ref == 'refs/heads/main' }} @@ -19,44 +21,39 @@ jobs: uses: actions/checkout@v2 with: fetch-depth: 0 - - name: Set up Python 3.8 + - name: Set up Python ${{ env.PYTHON_VER }} uses: actions/setup-python@v2 with: - python-version: 3.8 + python-version: ${{ env.PYTHON_VER }} + - uses: actions/cache@v2 + if: startsWith(runner.os, 'Windows') + with: + path: ~\AppData\Local\pip\Cache + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pip- - name: Install dependencies run: | python -m pip install --upgrade pip + pip install wheel pip install -r ./requirements.txt -t ./lib - - name: Determine versioning + - name: Get Plugin's version id: version - uses: paulhatch/semantic-version@v4.0.1 - with: - tag_prefix: "v" - major_pattern: "(MAJOR)" - minor_pattern: "(MINOR)" - format: "${major}.${minor}.${patch}" - short_tags: false - bump_each_commit: false - - name: "Update plugin.json version to: ${{steps.version.outputs.prop}}" - uses: jossef/action-set-json-field@v1 - with: - file: 'plugin.json' - field: Version - value: "${{steps.version.outputs.major}}.${{steps.version.outputs.minor}}.${{steps.version.outputs.patch}}" + uses: notiz-dev/github-action-json-property@release + with: + path: 'plugin.json' + prop_path: 'Version' - name: Package files run: | git clone https://github.com/Garulf/flow_commands/ bin pip install -r ./bin/requirements.txt python ./bin/commands.py package -n "${{github.event.repository.name}}.zip" - - name: Delete previous drafts - uses: hugo19941994/delete-draft-releases@v0.1.0 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Publish uses: softprops/action-gh-release@v1 with: - draft: true + draft: false files: "./${{github.event.repository.name}}.zip" - tag_name: "v${{steps.version.outputs.version}}" + tag_name: "v${{steps.version.outputs.prop}}" + generate_release_notes: true env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..d0e4d9a --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,71 @@ +name: "Test" +on: + pull_request: + workflow_dispatch: + push: + tags-ignore: + - 'v*' + paths-ignore: + - .github/workflows/* + - README.md + - assets/* +env: + PYTHON_VER: 3.8 +jobs: + deps: + name: "Test" + runs-on: windows-latest + steps: + - name: Load Cache + uses: actions/cache@v2 + if: startsWith(runner.os, 'Windows') + with: + path: .\Flow-Launcher-Setup.exe + key: ${{ runner.os }}-flow- + - name: Download Flow Launcher + run: | + if (-Not (Test-Path .\Flow-Launcher-Setup.exe)) + { + curl.exe -L -o Flow-Launcher-Setup.exe "https://github.com/Flow-Launcher/Flow.Launcher/releases/latest/download/Flow-Launcher-Setup.exe" + } + - name: Install Flow Launcher + run: .\Flow-Launcher-Setup.exe + shell: cmd + - name: Checkout Plugin Repo + uses: actions/checkout@v2 + with: + path: ${{github.event.repository.name}} + - name: Move checkout repo + run: | + $repo_path = Join-Path -Path $pwd -ChildPath ${{github.event.repository.name}} + $plugin_path = Join-Path -Path $env:APPDATA -ChildPath 'FlowLauncher' | Join-Path -ChildPath 'Plugins' | Join-Path -ChildPath ${{github.event.repository.name}} + New-Item -ItemType SymbolicLink -Path $plugin_path -Target $repo_path + echo "PLUGIN_PATH=$plugin_path" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.8 + - uses: actions/cache@v2 + with: + path: ~\AppData\Local\pip\Cache + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pip- + - name: Install dependencies + run: | + cd ${{ env.PLUGIN_PATH }} + python -m pip install --upgrade pip + pip install wheel + pip install -r ./requirements.txt -t ./lib + - name: Get Plugin's Execute file + id: exe + uses: notiz-dev/github-action-json-property@release + with: + path: '${{ env.PLUGIN_PATH }}/plugin.json' + prop_path: 'ExecuteFileName' + - name: Test Run + run: | + cd ${{ env.PLUGIN_PATH }} + echo ${{ env.PLUGIN_PATH }} + echo ${{steps.exe.outputs.prop}} + python ${{steps.exe.outputs.prop}}