Skip to content

CI: Support uploading tarball to release #2646

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -493,3 +493,32 @@ jobs:
run: |
cd integration_tests
./run_tests.py -b cpython c_py

upload_tarball:
name: Upload Tarball
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: mamba-org/setup-micromamba@v1
with:
environment-file: ci/environment.yml
create-args: >-
python=3.10

- name: Create Source Tarball
shell: bash -e -l {0}
run: |
./build0.sh
lpython_version=$(<version)
ci/create_source_tarball.sh $lpython_version

- name: Upload Tarball to Release
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
shell: bash -e -l {0}
run: |
ci/upload_tarball_to_release.sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4 changes: 2 additions & 2 deletions ci/create_source_tarball.sh
Original file line number Diff line number Diff line change
@@ -2,6 +2,6 @@

set -ex

lfortran_version=$1
export dest=lfortran-$lfortran_version
lpython_version=$1
export dest=lpython-$lpython_version
bash -x -o errexit ci/create_source_tarball0.sh
23 changes: 23 additions & 0 deletions ci/upload_tarball_to_release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash

set -ex

lpython_version=$(<version)

cd ./dist


RELEASE_ID=$(\
curl -s 'https://api.github.com/repos/lcompilers/lpython/releases/latest' | \
python -c "import sys, json; print(json.load(sys.stdin)['id'], end='')")

echo "RELEASE_ID=$RELEASE_ID"

curl --fail -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-H "Content-Type: application/octet-stream" \
"https://uploads.github.com/repos/lcompilers/lpython/releases/$RELEASE_ID/assets?name=lpython-${lpython_version}.tar.gz" \
--data-binary "@lpython-${lpython_version}.tar.gz"
Loading