1name: generator-tool 2on: push 3jobs: 4 build: 5 runs-on: ubuntu-latest 6 container: debian:10.13 7 steps: 8 - uses: actions/checkout@v3 9 10 - name: Cache dependencies 11 uses: actions/cache@v3 12 with: 13 key: debian-10.13-clang16 14 path: | 15 ${{github.workspace}}/build/_deps 16 17 - name: Install build tools 18 run: | 19 apt-get update 20 env DEBIAN_FRONTEND=noninteractive \ 21 apt-get install -qy --no-install-recommends \ 22 build-essential \ 23 ca-certificates \ 24 cmake \ 25 file \ 26 git \ 27 gnupg \ 28 libc6-dev \ 29 lsb-release \ 30 make \ 31 ninja-build \ 32 software-properties-common \ 33 wget 34 wget https://apt.llvm.org/llvm.sh 35 chmod +x llvm.sh 36 ./llvm.sh 16 all 37 38 - name: Configure CMake 39 run: | 40 mkdir -p "$GITHUB_WORKSPACE/build" 41 cmake \ 42 -S "$GITHUB_WORKSPACE" \ 43 -B "$GITHUB_WORKSPACE/build" \ 44 -G Ninja \ 45 -DCMAKE_BUILD_TYPE=Release \ 46 -DSAPI_ENABLE_CLANG_TOOL=ON \ 47 -DSAPI_ENABLE_CLANG_TOOL_STATIC=ON 48 49 - name: Build 50 run: | 51 cmake \ 52 --build "$GITHUB_WORKSPACE/build" \ 53 --config Release \ 54 --target sapi_generator_tool 55 ( \ 56 cd "$GITHUB_WORKSPACE/build"; \ 57 mv sandboxed_api/tools/clang_generator/sapi_generator_tool \ 58 sapi_generator_tool-linux-x86_64; \ 59 ) 60 61 - name: Upload Build Artifact 62 uses: actions/upload-artifact@v3.1.2 63 with: 64 name: sapi_generator_tool-linux 65 path: ${{github.workspace}}/build/sapi_generator_tool-linux-x86_64 66 67 prerelease: 68 needs: build 69 runs-on: ubuntu-latest 70 env: 71 ARTIFACT_NAME: sapi_generator_tool-linux 72 73 steps: 74 - uses: actions/checkout@v3 75 76 - name: Prepare environment 77 run: mkdir -p "$GITHUB_WORKSPACE/build" 78 79 - name: Download Build Artifact 80 uses: actions/github-script@v6 81 with: 82 script: | 83 let artifactName = process.env.ARTIFACT_NAME; 84 let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({ 85 owner: context.repo.owner, 86 repo: context.repo.repo, 87 run_id: context.payload.workflow_run.id, 88 }); 89 let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => { 90 return artifact.name == artifactName 91 })[0]; 92 let download = await github.rest.actions.downloadArtifact({ 93 owner: context.repo.owner, 94 repo: context.repo.repo, 95 artifact_id: matchArtifact.id, 96 archive_format: 'zip', 97 }); 98 let fs = require('fs'); 99 fs.writeFileSync( 100 `${process.env.GITHUB_WORKSPACE}/build/${artifactName}.zip`, 101 Buffer.from(download.data) 102 ); 103 104 - name: "Repackage as *-<arch>.tar.gz" 105 run: | 106 ( \ 107 cd "$GITHUB_WORKSPACE/build"; \ 108 unzip "${ARTIFACT_NAME}.zip"; \ 109 tar czf sapi_generator_tool-linux-x86_64.tar.gz \ 110 sapi_generator_tool-linux-x86_64 111 ) 112 113 - name: Create Pre-release 114 uses: marvinpinto/action-automatic-releases@v1.2.1 115 with: 116 repo_token: "${{secrets.GITHUB_TOKEN}}" 117 automatic_release_tag: "latest" 118 prerelease: true 119 files: | 120 ${{github.workspace}}/build/sapi_generator_tool-linux-x86_64.tar.gz 121 122