Skip to content

Commit d08a478

Browse files
authored
CI: Support uploading tarball to release (#2646)
* CI: Support uploading tarball to release * Using environment.yml
1 parent 760c898 commit d08a478

File tree

3 files changed

+54
-2
lines changed

3 files changed

+54
-2
lines changed

.github/workflows/CI.yml

+29
Original file line numberDiff line numberDiff line change
@@ -493,3 +493,32 @@ jobs:
493493
run: |
494494
cd integration_tests
495495
./run_tests.py -b cpython c_py
496+
497+
upload_tarball:
498+
name: Upload Tarball
499+
runs-on: ubuntu-latest
500+
steps:
501+
- uses: actions/checkout@v4
502+
with:
503+
fetch-depth: 0
504+
505+
- uses: mamba-org/setup-micromamba@v1
506+
with:
507+
environment-file: ci/environment.yml
508+
create-args: >-
509+
python=3.10
510+
511+
- name: Create Source Tarball
512+
shell: bash -e -l {0}
513+
run: |
514+
./build0.sh
515+
lpython_version=$(<version)
516+
ci/create_source_tarball.sh $lpython_version
517+
518+
- name: Upload Tarball to Release
519+
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
520+
shell: bash -e -l {0}
521+
run: |
522+
ci/upload_tarball_to_release.sh
523+
env:
524+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

ci/create_source_tarball.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
set -ex
44

5-
lfortran_version=$1
6-
export dest=lfortran-$lfortran_version
5+
lpython_version=$1
6+
export dest=lpython-$lpython_version
77
bash -x -o errexit ci/create_source_tarball0.sh

ci/upload_tarball_to_release.sh

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env bash
2+
3+
set -ex
4+
5+
lpython_version=$(<version)
6+
7+
cd ./dist
8+
9+
10+
RELEASE_ID=$(\
11+
curl -s 'https://api.github.com/repos/lcompilers/lpython/releases/latest' | \
12+
python -c "import sys, json; print(json.load(sys.stdin)['id'], end='')")
13+
14+
echo "RELEASE_ID=$RELEASE_ID"
15+
16+
curl --fail -L \
17+
-X POST \
18+
-H "Accept: application/vnd.github+json" \
19+
-H "Authorization: Bearer $GITHUB_TOKEN" \
20+
-H "X-GitHub-Api-Version: 2022-11-28" \
21+
-H "Content-Type: application/octet-stream" \
22+
"https://uploads.github.com/repos/lcompilers/lpython/releases/$RELEASE_ID/assets?name=lpython-${lpython_version}.tar.gz" \
23+
--data-binary "@lpython-${lpython_version}.tar.gz"

0 commit comments

Comments
 (0)