diff --git a/.github/workflows/manual.yml b/.github/workflows/manual.yml new file mode 100644 index 0000000..8893be7 --- /dev/null +++ b/.github/workflows/manual.yml @@ -0,0 +1,138 @@ +# This is a basic workflow that is manually triggered + +name: Manual workflow + +# Controls when the action will run. Workflow runs when manually triggered using the UI +# or API. +on: + schedule: + - cron: '23 21 * * 1' + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "greet" + check-version: + name: check the latest version + # The type of runner that the job will run on + runs-on: ubuntu-20.04 + outputs: + RELEASE_VERSION: ${{ steps.getLatestRelease.outputs.RELEASE_VERSION }} + LATEST_VERSION: ${{ steps.checkVersion.outputs.LATEST_VERSION }} + steps: + - name: Get Latest Release + id: getLatestRelease + uses: actions/github-script@v3.1.0 + with: + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + const releaseResponse = await github.repos.getLatestRelease({ + owner: 'Mas0nShi', + repo: 'typoraCracker', + }) + const { + data: { tag_name: ver } + } = releaseResponse; + core.setOutput('RELEASE_VERSION', ver); + + - uses: actions/checkout@v3 + - uses: actions/setup-python@v3 + with: + python-version: '3.8' # Version range or exact version of a Python version to use, using SemVer's version range syntax + architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified + - name: install dependencies + run: | + sudo apt-get update && DEBIAN_FRONTEND=noninteractive sudo apt-get install build-essential tree ninja-build gcc-multilib g++-multilib lib32stdc++-9-dev flex bison xz-utils ruby ruby-dev python3-requests python3-setuptools python3-dev python3-pip libc6-dev libc6-dev-i386 -y + python3 -m pip install r2pipe + + - name: build radare2 and innoextract + shell: bash + run: | + git clone https://github.com/radareorg/radare2 + sudo radare2/sys/install.sh + git clone https://github.com/dscharrer/innoextract + cd innoextract && mkdir -p build && cd build && cmake .. && make && make install && cd ../../ + + - name: Check Latest Version + run: | + output=$(python check_version.py ) + echo '::set-output name=LATEST_VERSION::$output' + + create-release: + needs: check-version + runs-on: ubuntu-20.04 + if: needs.check_version.outputs.RELEASE_VERSION != needs.check_version.outputs.LATEST_VERSION + + steps: + - uses: actions/create-release@master + id: createRelease + name: Create Runner Release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: "${{ needs.check_version.outputs.LATEST_VERSION }}" + release_name: "${{ needs.check_version.outputs.LATEST_VERSION }}" + prerelease: false + + patch_file: + needs: [check-version, create-release] + runs-on: ubuntu-20.04 + if: needs.check_version.outputs.RELEASE_VERSION != needs.check_version.outputs.LATEST_VERSION + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v3 + with: + python-version: '3.8' # Version range or exact version of a Python version to use, using SemVer's version range syntax + architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified + - name: install dependencies + run: | + sudo apt-get update && DEBIAN_FRONTEND=noninteractive sudo apt-get install build-essential tree ninja-build gcc-multilib g++-multilib lib32stdc++-9-dev flex bison xz-utils ruby ruby-dev python3-requests python3-setuptools python3-dev python3-pip libc6-dev libc6-dev-i386 -y + python3 -m pip install r2pipe + + - name: build radare2 and innoextract + shell: bash + run: | + git clone https://github.com/radareorg/radare2 + sudo radare2/sys/install.sh + git clone https://github.com/dscharrer/innoextract + cd innoextract && mkdir -p build && cd build && cmake .. && make && make install + + - name: patch version + + run: | + python3 auto-analysis/patch.py + tar -zcvf typoraCracker.tar.gz auto-analysis/win/x64/build/* + + - name: Check release version + id: checkReleaseVersion + uses: actions/github-script@v3.1.0 + with: + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + try { + const releaseVersion = '${{ needs.check_version.outputs.LATEST_VERSION }}' + const releaseResponse = await github.repos.getReleaseByTag({ + owner: 'Mas0nShi', + repo: 'typoraCracker', + tag: releaseVersion + }) + const { + data: { id: releaseId, html_url: htmlUrl, upload_url: uploadUrl } + } = releaseResponse; + core.setOutput('id', releaseId); + core.setOutput('html_url', htmlUrl); + core.setOutput('upload_url', uploadUrl); + core.setOutput('version', releaseVersion); + } catch (e) { + core.setFailed(e.message); + } + + - name: Upload win x64 typora.py for typoraCracker + uses: actions/upload-release-asset@v1.0.2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: '${{ steps.checkReleaseVersion.outputs.upload_url }}' + asset_path: '${{ github.workspace }}/auto-analysis/win/x64/build/typoraCracker.tar.gz' + asset_name: '${{ needs.check_version.outputs.LATEST_VERSION }}-win-x64.tar.gz' + asset_content_type: application/x-tgz +