diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index f805b85..0000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,44 +0,0 @@ -name: Build - -on: - workflow_dispatch: - push: - branches: [ main ] - paths-ignore: - - .github/workflows/* - - README.md - - assets/* - -env: - PYTHON_VER: 3.6 - - -jobs: - build: - name: Build Plugin - runs-on: windows-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - 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 -r ./requirements.txt -t ./lib - Move-Item -Path .\lib\flox -Destination . - Remove-Item .\Flox-*-info -Recurse - - name: Upload Artifact - uses: actions/upload-artifact@v2 - with: - name: build-artifact - path: . # or path/to/artifact diff --git a/.github/workflows/dev-build.yml b/.github/workflows/dev-build.yml new file mode 100644 index 0000000..a590c74 --- /dev/null +++ b/.github/workflows/dev-build.yml @@ -0,0 +1,64 @@ +name: "pre-release" + +on: + workflow_dispatch: + push: + branches: [ main ] + tags-ignore: + - 'v*' + paths-ignore: + - .github/workflows/* + - README.md + - assets/* + +jobs: + deps: + name: "Install Dependencies" + runs-on: windows-latest + steps: + steps: + - name: Checkout + uses: actions/checkout@v2 + - 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 -r ./requirements.txt -t ./lib + - name: Upload Artifact + uses: actions/upload-artifact@v2 + with: + name: build-artifact + path: . + package: + name: Package Plugin + needs: deps + runs-on: "ubuntu-latest" + - name: Get release version + run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV + - name: "Update plugin.json version to: ${{ env.VERSION }}" + uses: jossef/action-set-json-field@v1 + with: + file: plugin.json + field: Version + value: "${{ env.VERSION }}-dev" + - name: Package files + run: | + zip -r "${{github.event.repository.name}}.zip" . -x '*.git*' -x 'demo.gif' -x 'README.md' -x 'assets/*' + - uses: "marvinpinto/action-automatic-releases@latest" + with: + repo_token: "${{ secrets.GITHUB_TOKEN }}" + automatic_release_tag: "dev" + prerelease: true + title: "Dev Build" + files: | + "${{github.event.repository.name}}.zip" \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9c9a30c..13d9245 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,72 +1,61 @@ name: Release on: - workflow_dispatch: push: branches: [ main ] tags: - 'v*' - paths-ignore: - - .github/workflows/* - - README.md - - assets/* - -env: - PYTHON_VER: 3.6 jobs: - package: + release: name: Package Release - needs: build runs-on: ubuntu-latest - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - REPO_SLUG: ${{ github.repository }} - BRANCH: "main" - WORKFLOW: "build.yml" steps: - - id: curl - run: | - RUN_ID=$(curl -sLH 'Accept: application/vnd.github.v3+json' -H "Authorization: token $GITHUB_TOKEN" "api.github.com/repos/$REPO_SLUG/actions/workflows/$WORKFLOW/runs" | jq --arg branch "$BRANCH" -c '[.workflow_runs[] | select( .conclusion == "success" and .head_branch == $branch)][0] | .id') - echo "::set-output name=RUN_ID::$RUN_ID" - - name: Get release version - run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV - - name: Download artifact - uses: dawidd6/action-download-artifact@v2 - with: - github_token: ${{secrets.GITHUB_TOKEN}} - run_id: ${{ steps.curl.outputs.RUN_ID }} - name: build - workflow: ${{ env.WORKFLOW }} - path: . + - name: Checkout + uses: actions/checkout@v2 - name: "Update plugin.json version to: ${{ env.VERSION }}" uses: jossef/action-set-json-field@v1 with: file: plugin.json field: Version value: ${{ env.VERSION }} + - name: Get release version + run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV - name: Commit version change run: | git config --local user.email "action@github.com" git config --local user.name "GitHub Action" git add ./plugin.json - git commit -m "bumping release ${{ env.VERSION }}" + git commit -m "bumping versioning ${{ env.VERSION }}" - name: Push changes uses: ad-m/github-push-action@v0.6.0 with: github_token: ${{ github.token }} - - name: Move Flox to plugin root + - name: Download dev build + uses: dsaltares/fetch-gh-release-asset@master + with: + repo: ${{ github.repository }} + version: "tags/dev" + file: "${{github.event.repository.name}}.zip" + token: ${{ secrets.GITHUB_TOKEN }} + - name: Unzip prelease run: | - mv ./lib/flox . && rm -r ./lib/Flox-*-info - - name: Package files + mkdir -p ./staging + unzip -d ./staging "${{github.event.repository.name}}.zip" + mv ./plugin.json ./staging + - name: Zip release run: | + cd ./staging zip -r "${{github.event.repository.name}}.zip" . -x '*.git*' -x 'demo.gif' -x 'README.md' -x 'assets/*' - name: Publish + uses: "marvinpinto/action-automatic-releases@latest" if: success() - uses: softprops/action-gh-release@v1 with: - files: "${{github.event.repository.name}}.zip" - tag_name: "v${{ env.VERSION }}" - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + repo_token: "${{ secrets.GITHUB_TOKEN }}" + automatic_release_tag: "v${{ env.VERSION }}" + prerelease: false + title: "v${{ env.VERSION }}" + files: | + "${{github.event.repository.name}}.zip" + diff --git a/main.py b/main.py index d84bfe9..ed2b899 100644 --- a/main.py +++ b/main.py @@ -2,6 +2,11 @@ import sys import os +plugindir = os.path.abspath(os.path.dirname(__file__)) +sys.path.append(plugindir) +sys.path.append(os.path.join(plugindir, 'lib')) +sys.path.append(os.path.join(plugindir, 'plugin')) + from plugin.main import Commander if __name__ == "__main__":