Skip to content

Commit

Permalink
CI: Support uploading tarball to release (#2646)
Browse files Browse the repository at this point in the history
* CI: Support uploading tarball to release

* Using environment.yml
  • Loading branch information
anutosh491 authored Apr 12, 2024
1 parent 760c898 commit d08a478
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 2 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Up @@ -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"

0 comments on commit d08a478

Please sign in to comment.