Skip to content

Commit db7375b

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 db7375b

File tree

1 file changed

+115
-1
lines changed

1 file changed

+115
-1
lines changed

.github/workflows/ci.yml

Lines changed: 115 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ jobs:
179179
echo -E "llvm-hash=e1065370aaacb1b1cb48e77d37d376bf024f4a39" >> $GITHUB_OUTPUT
180180
echo -E "llvm-id=e1065370" >> $GITHUB_OUTPUT
181181
echo -E "llvm-build-preset=${{ runner.os == 'Windows' && 'release-win' || 'release-unix' }}" >> $GITHUB_OUTPUT
182+
echo -E "llvm-cache-key=llvm-libcxx-${{ runner.os }}-${{ matrix.compiler }}-${{ matrix.version }}-${{ steps.llvm-parameters.outputs.llvm-build-preset }}-${{ steps.llvm-parameters.outputs.llvm-hash }}" >> $GITHUB_OUTPUT
182183
cd ..
183184
llvm_root=$(pwd)/third-party/llvm-project/install
184185
if [[ ${{ runner.os }} == 'Windows' ]]; then
@@ -193,7 +194,7 @@ jobs:
193194
uses: actions/cache@v4
194195
with:
195196
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 }}
197+
key: ${{ steps.llvm-parameters.outputs.llvm-cache-key }}
197198

198199
- name: Install LLVM
199200
id: llvm-install
@@ -597,3 +598,116 @@ jobs:
597598
env:
598599
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
599600

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

0 commit comments

Comments
 (0)