Skip to content

Commit 63c958a

Browse files
committed
ci: llvm releases
Update the workflow to upload the LLVM release built in CI whenever there's a new version.
1 parent ce34057 commit 63c958a

File tree

1 file changed

+124
-5
lines changed

1 file changed

+124
-5
lines changed

.github/workflows/ci.yml

Lines changed: 124 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,13 @@ jobs:
176176
- name: LLVM Parameters
177177
id: llvm-parameters
178178
run: |
179-
echo -E "llvm-hash=e1065370aaacb1b1cb48e77d37d376bf024f4a39" >> $GITHUB_OUTPUT
180-
echo -E "llvm-id=e1065370" >> $GITHUB_OUTPUT
181-
echo -E "llvm-build-preset=${{ runner.os == 'Windows' && 'release-win' || 'release-unix' }}" >> $GITHUB_OUTPUT
179+
llvm_hash=e1065370aaacb1b1cb48e77d37d376bf024f4a39
180+
echo -E "llvm-hash=$llvm_hash" >> $GITHUB_OUTPUT
181+
llvm_id=$(echo $llvm_hash | cut -c1-7)
182+
echo -E "llvm-id=$llvm_id" >> $GITHUB_OUTPUT
183+
llvm_build_preset=${{ runner.os == 'Windows' && 'release-win' || 'release-unix' }}
184+
echo -E "llvm-build-preset=$llvm_build_preset" >> $GITHUB_OUTPUT
185+
echo -E "llvm-cache-key=llvm-libcxx-${{ runner.os }}-${{ matrix.compiler }}-${{ matrix.version }}-$llvm_build_preset-$llvm_hash" >> $GITHUB_OUTPUT
182186
cd ..
183187
llvm_root=$(pwd)/third-party/llvm-project/install
184188
if [[ ${{ runner.os }} == 'Windows' ]]; then
@@ -193,7 +197,7 @@ jobs:
193197
uses: actions/cache@v4
194198
with:
195199
path: ${{ steps.llvm-parameters.outputs.llvm-root }}
196-
key: llvm-libcxx-${{ runner.os }}-${{ matrix.compiler }}-${{ matrix.version }}-${{ steps.llvm-parameters.outputs.llvm-build-preset }}-${{ steps.llvm-parameters.outputs.llvm-hash }}
200+
key: ${{ steps.llvm-parameters.outputs.llvm-cache-key }}
197201

198202
- name: Install LLVM
199203
id: llvm-install
@@ -333,7 +337,7 @@ jobs:
333337
run:
334338
shell: bash
335339
name: Releases
336-
timeout-minutes: 30
340+
timeout-minutes: 30
337341
runs-on: ubuntu-latest
338342
container: ubuntu:20.04
339343
permissions:
@@ -597,3 +601,118 @@ jobs:
597601
env:
598602
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
599603

604+
llvm-releases:
605+
needs: build
606+
607+
strategy:
608+
fail-fast: false
609+
matrix:
610+
include: ${{ fromJSON(needs.cpp-matrix.outputs.matrix) }}
611+
612+
defaults:
613+
run:
614+
shell: bash
615+
616+
name: ${{ matrix.name }}-LLVM-Release
617+
runs-on: ${{ matrix.runs-on }}
618+
container: ${{ matrix.container }}
619+
env: ${{ matrix.env }}
620+
permissions:
621+
contents: write
622+
623+
steps:
624+
- name: Install packages
625+
uses: alandefreitas/cpp-actions/[email protected]
626+
id: package-install
627+
with:
628+
apt-get: build-essential asciidoctor cmake bzip2 git
629+
630+
- name: LLVM Parameters
631+
id: llvm-parameters
632+
run: |
633+
llvm_hash=e1065370aaacb1b1cb48e77d37d376bf024f4a39
634+
echo -E "llvm-hash=$llvm_hash" >> $GITHUB_OUTPUT
635+
llvm_id=$(echo $llvm_hash | cut -c1-7)
636+
echo -E "llvm-id=$llvm_id" >> $GITHUB_OUTPUT
637+
llvm_build_preset=${{ runner.os == 'Windows' && 'release-win' || 'release-unix' }}
638+
echo -E "llvm-build-preset=$llvm_build_preset" >> $GITHUB_OUTPUT
639+
echo -E "llvm-cache-key=llvm-libcxx-${{ runner.os }}-${{ matrix.compiler }}-${{ matrix.version }}-$llvm_build_preset-$llvm_hash" >> $GITHUB_OUTPUT
640+
llvm_archive_basename=llvm-${{ runner.os }}-$llvm_id
641+
echo -E "llvm-archive-basename=$llvm_archive_basename" >> $GITHUB_OUTPUT
642+
if [[ ${{ runner.os }} == 'Windows' ]]; then
643+
llvm_archive_extension=7z
644+
else
645+
llvm_archive_extension=tar.bz2
646+
fi
647+
echo -E "llvm-archive-extension=$llvm_archive_extension" >> $GITHUB_OUTPUT
648+
llvm_archive_filename=$llvm_archive_basename.$llvm_archive_extension
649+
echo -E "llvm-archive-filename=$llvm_archive_filename" >> $GITHUB_OUTPUT
650+
651+
cd ..
652+
llvm_root=$(pwd)/third-party/llvm-project/install
653+
if [[ ${{ runner.os }} == 'Windows' ]]; then
654+
llvm_root=$(echo "$llvm_root" | sed 's/\\/\//g')
655+
llvm_root=$(echo $llvm_root | sed 's|^/d/|D:/|')
656+
echo "$llvm_root"
657+
fi
658+
echo -E "llvm-root=$llvm_root" >> $GITHUB_OUTPUT
659+
660+
- name: Check website releases
661+
id: website-releases
662+
run: |
663+
set -x
664+
archive_url="https://mrdocs.com/llvm+clang/${{ steps.llvm-parameters.outputs.llvm-archive-filename }}"
665+
http_status=$(curl -s -o /dev/null -w "%{http_code}" "$archive_url")
666+
if [ "$http_status" -eq 200 ]; then
667+
exists="true"
668+
else
669+
exists="false"
670+
fi
671+
echo "exists=$exists" >> $GITHUB_OUTPUT
672+
673+
- name: LLVM Binaries
674+
id: llvm-cache
675+
if: steps.website-releases.outputs.exists != 'true'
676+
uses: actions/cache@v4
677+
with:
678+
path: ${{ steps.llvm-parameters.outputs.llvm-root }}
679+
key: ${{ steps.llvm-parameters.outputs.llvm-cache-key }}
680+
681+
- name: Compress LLVM
682+
id: llvm-upload
683+
if: steps.llvm-cache.outputs.cache-hit == 'true'
684+
shell: bash
685+
run: |
686+
# LLVM is be installed with the default compiler
687+
set -x
688+
689+
# Compress the LLVM installation
690+
cd ../third-party/llvm-project
691+
692+
# Use 7z on windows
693+
if [[ ${{ runner.os }} == 'Windows' ]]; then
694+
7z a -t7z -m0=lzma2 -mx=9 -mfb=64 -md=32m -ms=on ${{ steps.llvm-parameters.outputs.llvm-archive-filename }} install
695+
else
696+
tar -cjf ${{ steps.llvm-parameters.outputs.llvm-archive-filename }} -C install .
697+
fi
698+
699+
- name: Publish website
700+
if: steps.llvm-cache.outputs.cache-hit == 'true' && github.event_name == 'push' && (contains(fromJSON('["master", "develop"]'), github.ref_name) || startsWith(github.ref, 'refs/tags/'))
701+
working-directory: ../third-party/llvm-project
702+
env:
703+
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
704+
run: |
705+
# Add SSH key
706+
mkdir -p /home/runner/.ssh
707+
ssh-keyscan dev-websites.cpp.al >> /home/runner/.ssh/known_hosts
708+
chmod 600 /home/runner/.ssh/known_hosts
709+
echo "${{ secrets.DEV_WEBSITES_SSH_KEY }}" > /home/runner/.ssh/github_actions
710+
chmod 600 /home/runner/.ssh/github_actions
711+
ssh-agent -a $SSH_AUTH_SOCK > /dev/null
712+
ssh-add /home/runner/.ssh/github_actions
713+
714+
# Remove previous demos associated with this tag
715+
llvm_dir="/var/www/mrdox.com/llvm+clang"
716+
chmod 755 -R ${{ steps.llvm-parameters.outputs.llvm-archive-filename }}
717+
scp -o StrictHostKeyChecking=no $(pwd)/${{ steps.llvm-parameters.outputs.llvm-archive-filename }} [email protected]:$llvm_dir/
718+

0 commit comments

Comments
 (0)