From 72bd8b6b46e7fd26146198c6ea8b9e5482365d5f Mon Sep 17 00:00:00 2001 From: Cyb3r Jak3 Date: Fri, 6 Oct 2023 18:14:02 -0400 Subject: [PATCH] Generate releases (#8) * Action to generate a release * Register workflow * Fix script to fail * Update token permissions * Change name of checksums file * Raise error if file not downloaded * Update README --- .github/release.py | 30 +++++++++++++ .github/workflows/generate-release.yml | 58 ++++++++++++++++++++++++++ README.md | 24 ++++++----- 3 files changed, 101 insertions(+), 11 deletions(-) create mode 100644 .github/release.py create mode 100644 .github/workflows/generate-release.yml diff --git a/.github/release.py b/.github/release.py new file mode 100644 index 0000000..938ca31 --- /dev/null +++ b/.github/release.py @@ -0,0 +1,30 @@ +import os +import requests + +def save_file(url: str) -> None: + """Saves a file from R2""" + resp = requests.get(url, timeout=300) + if resp.status_code == 200: + with open(url.split("/")[-1], "wb") as file: + file.write(resp.content) + else: + raise Exception(f"Failed to download {url} with status code {resp.status_code}") + +def main(): + PYPY_BASE = os.environ["PYPY_BASE"] + PYPY_VERSION = os.environ["PYPY_VERSION"] + PYPY_BASES= PYPY_BASE.split(",") + ARCHES = ["x86_64", "aarch64"] + base_url= "https://pypy.cyberjake.xyz/pypy/{base}/pypy{base}-v{pypy_version}-linux-{arch}-alpine.tar.bz2" + for base in PYPY_BASES: + for arch in ARCHES: + file_url = base_url.format( + base=base, + pypy_version=PYPY_VERSION, + arch=arch + ) + save_file(file_url) + save_file(f"{file_url}.sig") + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/.github/workflows/generate-release.yml b/.github/workflows/generate-release.yml new file mode 100644 index 0000000..c44f61f --- /dev/null +++ b/.github/workflows/generate-release.yml @@ -0,0 +1,58 @@ +name: Generate Release + +on: + workflow_dispatch: + inputs: + pypy_base: + description: 'Comma seperated base version: 2.7,3.9,3.10' + required: true + pypy_version: + description: 'PyPy version to build: 7.3.13' + required: true + +jobs: + generate-release: + runs-on: ubuntu-latest + permissions: + contents: write + env: + TAG: "${{ github.event.inputs.pypy_version }}-${{ github.event.inputs.pypy_base }}" + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Release Info + run: | + echo "::notice title=PYPY_BASE::${{ github.event.inputs.pypy_base }}" + echo "::notice title=PYPY_VERSION:: ${{ github.event.inputs.pypy_version }}" + + - name: Prep Release + run: python .github/release.py + env: + PYPY_BASE: ${{ github.event.inputs.pypy_base }} + PYPY_VERSION: ${{ github.event.inputs.pypy_version }} + + - name: Generate Checksums + run: | + ls -la *.tar.bz2* + sha256sum *.tar.bz2 > checksums.sha256 + + - name: Create tag + uses: actions/github-script@v6.4.1 + with: + script: | + github.rest.git.createRef({ + owner: context.repo.owner, + repo: context.repo.repo, + ref: 'refs/tags/${{ env.TAG }}', + sha: context.sha + }) + + - name: Release + uses: crazy-max/ghaction-github-release@v2 + with: + draft: trues + tag_name: ${{ env.TAG }} + files: | + *.tar.bz2 + *.tar.bz2.sig + checksums.sha256 diff --git a/README.md b/README.md index c899452..b30f053 100644 --- a/README.md +++ b/README.md @@ -52,16 +52,18 @@ PyPy: 3.9-7.3.11 is `https://pypy.cyberjake.xyz/pypy/3.9/pypy3.9-v7.3.11-linux-x ### Available Versions -| PyPy Base | PyPy Version | Alpine Version | Arch | -|:-----------:|:--------------:|:----------------:|:------------------:| -| 3.10 | 7.3.13 | 3.18 | x86_64 & aarch64 | -| 3.9 | 7.3.13 | 3.18 | x86_64 & aarch64 | -| 2.7 | 7.3.13 | 3.18 | x86_64 & aarch64 | -| 3.10 | 7.3.12 | 3.18 | x86_64 & aarch64 | -| 3.9 | 7.3.12 | 3.18 | x86_64 & aarch64 | -| 2.7 | 7.3.12 | 3.18 | x86_64 & aarch64 | -| 3.9 | 7.3.11 | 3.17 | x86_64 & aarch64 | -| 3.8 | 7.3.11 | 3.17 | x86_64 & aarch64 | -| 2.7 | 7.3.11 | 3.17 | x86_64 & aarch64 | +| PyPy Base | PyPy Version | Alpine Version | Arch | +|-----------|----------------|----------------|------------------| +| 3.10 | 7.3.12, 7.3.13 | 3.18 | x86_64 & aarch64 | +| 3.9 | 7.3.12, 7.3.13 | 3.18 | x86_64 & aarch64 | +| 2.7 | 7.3.12, 7.3.13 | 3.18 | x86_64 & aarch64 | +| 3.9 | 7.3.11 | 3.17 | x86_64 & aarch64 | +| 3.8 | 7.3.11 | 3.17 | x86_64 & aarch64 | +| 2.7 | 7.3.11 | 3.17 | x86_64 & aarch64 | Please make an issue if you want to see a specific version. + + +### GitHub Release + +Starting with pypy 7.3.13, you can download pypy builds under the [releases](https://github.com/Cyb3r-Jak3/docker-alpine-pypy/releases) section. \ No newline at end of file