diff --git a/.github/workflows/appimage.yml b/.github/workflows/appimage.yml index dff338b..6c38ba6 100644 --- a/.github/workflows/appimage.yml +++ b/.github/workflows/appimage.yml @@ -1,105 +1,36 @@ name: AppImage on: - push: - branches: - - master - paths: - - '.github/workflows/appimage.yml' - - 'python_appimage/**' + workflow_dispatch: + inputs: + dry: + description: 'Dry run' + required: true + type: boolean + all: + description: 'Update all' + required: true + type: boolean schedule: - cron: '0 3 * * 0' jobs: - Build: + Update: runs-on: ubuntu-latest - strategy: - matrix: - image: ['1', '2010', '2014', '2_24', '2_28'] - arch: [x86_64, i686] - tag: [cp27-cp27m, cp27-cp27mu, cp35-cp35m, cp36-cp36m, cp37-cp37m, - cp38-cp38, cp39-cp39, cp310-cp310, cp311-cp311] - exclude: - - image: '1' - tag: cp310-cp310 - - image: '1' - tag: cp311-cp311 - - image: '2010' - tag: cp27-cp27m - - image: '2010' - tag: cp27-cp27mu - - image: '2010' - tag: cp35-cp35m - - image: '2010' - tag: cp311-cp311 - - image: '2014' - tag: cp27-cp27m - - image: '2014' - tag: cp27-cp27mu - - image: '2014' - tag: cp35-cp35m - - image: '2_24' - tag: cp27-cp27m - - image: '2_24' - tag: cp27-cp27mu - - image: '2_24' - tag: cp35-cp35m - - image: '2_28' - tag: cp27-cp27m - - image: '2_28' - tag: cp27-cp27mu - - image: '2_28' - tag: cp35-cp35m - - image: '2_28' - arch: i686 + permissions: + contents: write steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - - name: Build - env: - ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true' + - name: Install Dependencies + run: pip install PyGithub + + - name: Run updater run: | - # Build the AppImage - python -m python_appimage build manylinux \ - ${{ matrix.image }}_${{ matrix.arch }} \ - ${{ matrix.tag }} - - # Export the AppImage name and the Python version - appimage=$(ls python*.AppImage) - SCRIPT=$(cat <<-END - version = '${appimage}'[6:].split('.', 2) - print('{:}.{:}'.format(*version[:2])) - END - ) - version=$(python -c "${SCRIPT}") - - echo "::set-env name=PYTHON_APPIMAGE::${appimage}" - echo "::set-env name=PYTHON_VERSION::${version}" - - - uses: actions/upload-artifact@v1 - if: github.ref == 'refs/heads/master' - with: - name: python${{ env.PYTHON_VERSION }}-appimages - path: ${{ env.PYTHON_APPIMAGE }} - - Release: - needs: Build - runs-on: ubuntu-latest - if: github.ref == 'refs/heads/master' - strategy: - matrix: - version: ['2.7', '3.5', '3.6', '3.7', '3.8', '3.9', '3.10', '3.11'] - - steps: - - uses: actions/download-artifact@v1 - with: - name: python${{ matrix.version }}-appimages - - - name: Release - uses: marvinpinto/action-automatic-releases@latest - with: - automatic_release_tag: python${{ matrix.version }} - title: Python ${{ matrix.version }} - files: | - python${{ matrix.version }}-appimages/python*.AppImage - repo_token: ${{ secrets.GITHUB_TOKEN }} + ./scripts/update-appimages.py \ + --token=${{ secrets.GITHUB_TOKEN }} \ + --sha=${{ github.sha }} \ + ${{ inputs.all && '--all' || '' }} \ + ${{ inputs.dry && '--dry' || '' }} + env: + PYTHONPATH: ${{ github.workspace }} diff --git a/.github/workflows/applications.yml b/.github/workflows/applications.yml index a1e4724..74abbda 100644 --- a/.github/workflows/applications.yml +++ b/.github/workflows/applications.yml @@ -1,12 +1,23 @@ name: Applications on: - push: - branches: - - master - paths: - - '.github/workflows/applications.yml' - - 'applications/**' - - 'python_appimage/**' + workflow_dispatch: + inputs: + scipy: + required: true + default: true + type: boolean + tasmotizer: + required: true + default: true + type: boolean + xonsh: + required: true + default: true + type: boolean + ssh-mitm: + required: true + default: true + type: boolean jobs: Test: @@ -16,12 +27,13 @@ jobs: version: ['2.7', '3.7', '3.9'] steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v1 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v4 with: python-version: ${{ matrix.version }} - name: Test scipy + if: ${{ inputs.scipy }} run: | python -m python_appimage build app applications/scipy \ --python-version=2.7 \ @@ -30,6 +42,7 @@ jobs: ./scipy-x86_64.AppImage -c 'import numpy, pandas, scipy' - name: Test tasmotizer + if: ${{ inputs.tasmotizer }} run: | python -m python_appimage build app applications/tasmotizer \ --linux-tag=manylinux1_x86_64 \ @@ -37,13 +50,14 @@ jobs: test -e tasmotizer-x86_64.AppImage - name: Test xonsh + if: ${{ inputs.xonsh }} run: | python -m python_appimage build app applications/xonsh test -e xonsh-x86_64.AppImage ./xonsh-x86_64.AppImage -c 'import xonsh' - name: Test ssh-mitm - if: ${{ matrix.version == '3.9' }} + if: ${{ inputs.ssh_mitm && (matrix.version == '3.9') }} run: | python -m python_appimage build app applications/ssh-mitm test -e ssh-mitm-x86_64.AppImage diff --git a/.github/workflows/delete-artifacts.yml b/.github/workflows/delete-artifacts.yml deleted file mode 100644 index 0c309b1..0000000 --- a/.github/workflows/delete-artifacts.yml +++ /dev/null @@ -1,13 +0,0 @@ -name: Delete artifacts -on: - schedule: - - cron: '0 3 * * 0' - -jobs: - delete-artifacts: - runs-on: ubuntu-latest - steps: - - uses: kolpav/purge-artifacts-action@v1 - with: - token: ${{ secrets.GITHUB_TOKEN }} - expire-in: 0days diff --git a/scripts/update-appimages.py b/scripts/update-appimages.py index 61ff2f3..4005e0c 100755 --- a/scripts/update-appimages.py +++ b/scripts/update-appimages.py @@ -4,6 +4,7 @@ from collections import defaultdict from dataclasses import dataclass import os import subprocess +import sys from typing import Optional from github import Auth, Github @@ -88,7 +89,8 @@ def update(args): ''' # Connect to GitHub - if args.token is None: + token = args.token + if token is None: # First, check for token in env token = os.getenv('GITHUB_TOKEN') if token is None: @@ -160,15 +162,17 @@ def update(args): new_releases.add(rtag) # Check SHA of tags. - sha = os.getenv('GITHUB_SHA') + sha = args.sha if sha is None: - p = subprocess.run( - 'git rev-parse HEAD', - shell = True, - capture_output = True, - check = True - ) - sha = p.stdout.decode().strip() + sha = os.getenv('GITHUB_SHA') + if sha is None: + p = subprocess.run( + 'git rev-parse HEAD', + shell = True, + capture_output = True, + check = True + ) + sha = p.stdout.decode().strip() for tag in releases.keys(): ref = repo.get_git_ref(f'tags/{tag}') @@ -256,9 +260,13 @@ if __name__ == '__main__': action = 'store_true', default = False ) + parser.add_argument("-s", "--sha", + help = "reference commit SHA" + ) parser.add_argument('-t', '--token', help = 'GitHub authentication token' ) args = parser.parse_args() + sys.argv = sys.argv[:1] # Empty args for fake call update(args)