CAMEL-23703: camel-launcher - secure website installers with immutabl… #87
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # | |
| # Licensed to the Apache Software Foundation (ASF) under one or more | |
| # contributor license agreements. See the NOTICE file distributed with | |
| # this work for additional information regarding copyright ownership. | |
| # The ASF licenses this file to You under the Apache License, Version 2.0 | |
| # (the "License"); you may not use this file except in compliance with | |
| # the License. You may obtain a copy of the License at | |
| # | |
| # http://www.apache.org/licenses/LICENSE-2.0 | |
| # | |
| # Unless required by applicable law or agreed to in writing, software | |
| # distributed under the License is distributed on an "AS IS" BASIS, | |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| # See the License for the specific language governing permissions and | |
| # limitations under the License. | |
| # | |
| name: Camel launcher Windows build | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - 'tooling/camel-exe/**' | |
| - 'dsl/camel-jbang/camel-launcher/**' | |
| - '.github/workflows/camel-launcher-windows.yml' | |
| pull_request: | |
| branches: | |
| - main | |
| paths: | |
| - 'tooling/camel-exe/**' | |
| - 'dsl/camel-jbang/camel-launcher/**' | |
| - '.github/workflows/camel-launcher-windows.yml' | |
| workflow_dispatch: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| jobs: | |
| detect-changes: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| camel-exe: ${{ steps.changes.outputs.camel-exe }} | |
| camel-launcher: ${{ steps.changes.outputs.camel-launcher }} | |
| steps: | |
| - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| with: | |
| persist-credentials: false | |
| fetch-depth: 0 | |
| - id: changes | |
| run: | | |
| if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | |
| echo "camel-exe=true" >> "$GITHUB_OUTPUT" | |
| echo "camel-launcher=true" >> "$GITHUB_OUTPUT" | |
| exit 0 | |
| fi | |
| if [ "${{ github.event_name }}" = "pull_request" ]; then | |
| CHANGED="$(git diff --name-only "origin/${{ github.base_ref }}"...HEAD)" | |
| else | |
| CHANGED="$(git diff --name-only "${{ github.event.before }}" "${{ github.sha }}")" | |
| fi | |
| echo "Changed files:" | |
| echo "$CHANGED" | |
| camel_exe=false | |
| camel_launcher=false | |
| if echo "$CHANGED" | grep -qE '^(tooling/camel-exe/|\.github/workflows/camel-launcher-windows\.yml)'; then | |
| camel_exe=true | |
| fi | |
| if echo "$CHANGED" | grep -qE '^(dsl/camel-jbang/camel-launcher/|tooling/camel-exe/|\.github/workflows/camel-launcher-windows\.yml)'; then | |
| camel_launcher=true | |
| fi | |
| echo "camel-exe=$camel_exe" >> "$GITHUB_OUTPUT" | |
| echo "camel-launcher=$camel_launcher" >> "$GITHUB_OUTPUT" | |
| camel-exe: | |
| needs: detect-changes | |
| if: github.event_name == 'workflow_dispatch' || needs.detect-changes.outputs.camel-exe == 'true' | |
| runs-on: windows-2022 | |
| steps: | |
| - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| with: | |
| persist-credentials: false | |
| - name: Set up JDK 21 | |
| uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '21' | |
| cache: 'maven' | |
| - name: Build and test native camel.exe | |
| shell: cmd | |
| run: | | |
| for /f "usebackq delims=" %%i in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath`) do set "VSINSTALL=%%i" | |
| call "%VSINSTALL%\VC\Auxiliary\Build\vcvars64.bat" | |
| mvn -B -ntp -pl buildingtools install -DskipTests | |
| mvn -B -ntp -pl tooling/camel-exe verify -Dcamel.exe.requireWindowsExe=true | |
| camel-launcher-windows: | |
| needs: detect-changes | |
| if: github.event_name == 'workflow_dispatch' || needs.detect-changes.outputs.camel-launcher == 'true' | |
| runs-on: windows-2022 | |
| steps: | |
| - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| with: | |
| persist-credentials: false | |
| - name: Set up JDK 21 | |
| uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '21' | |
| cache: 'maven' | |
| - name: Build launcher with native camel.exe | |
| shell: cmd | |
| run: | | |
| for /f "usebackq delims=" %%i in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath`) do set "VSINSTALL=%%i" | |
| call "%VSINSTALL%\VC\Auxiliary\Build\vcvars64.bat" | |
| mvn -B -ntp -pl buildingtools,tooling/camel-exe,dsl/camel-jbang/camel-launcher -am install -DskipTests -Dcamel.launcher.requireWindowsExe=true | |
| - name: Assert archive carries bin/camel.exe | |
| shell: pwsh | |
| run: | | |
| $zip = Get-ChildItem dsl/camel-jbang/camel-launcher/target/camel-launcher-*-bin.zip | Select-Object -First 1 | |
| Add-Type -AssemblyName System.IO.Compression.FileSystem | |
| $archive = [System.IO.Compression.ZipFile]::OpenRead($zip.FullName) | |
| try { | |
| $names = $archive.Entries.FullName | |
| if (-not ($names -like '*/bin/camel.exe')) { throw 'camel.exe missing from launcher archive' } | |
| } finally { | |
| $archive.Dispose() | |
| } |