====== 7.1 GitHub Actions ====== Diese Seite zeigt, wie Sie OpenSSL mit GitHub Actions automatisch bauen. ---- ===== Was ist GitHub Actions? ===== **GitHub Actions** ist die CI/CD-Plattform von GitHub: * Direkt in GitHub integriert * Kostenlos für öffentliche Repositories * YAML-basierte Konfiguration ---- ===== Grundkonzepte ===== | Begriff | Bedeutung | |---------|-----------| | **Workflow** | Die gesamte Automatisierung (.yml Datei) | | **Job** | Eine Gruppe von Schritten (z.B. "build-windows") | | **Step** | Ein einzelner Befehl oder Action | | **Runner** | Der Server, der den Job ausführt | | **Artifact** | Das Ergebnis (z.B. die DLLs) | ---- ===== Workflow-Datei erstellen ===== Erstellen Sie die Datei ''.github/workflows/build-openssl.yml'': # OpenSSL Build Workflow name: Build OpenSSL 3.6 # Wann wird gebaut? on: push: branches: [ main ] # Bei Push auf main pull_request: branches: [ main ] # Bei Pull Requests workflow_dispatch: # Manuell starten schedule: - cron: '0 2 * * 0' # Jeden Sonntag 2:00 Uhr jobs: # ============================================ # Windows x64 Build # ============================================ build-windows: runs-on: windows-latest steps: # 1. Repository auschecken - name: Checkout uses: actions/checkout@v4 with: submodules: true # 2. Perl installieren - name: Install Strawberry Perl run: choco install strawberryperl -y # 3. NASM installieren - name: Install NASM run: choco install nasm -y # 4. Build - name: Build OpenSSL shell: cmd run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" set PATH=C:\Strawberry\perl\bin;C:\Program Files\NASM;%PATH% cd src perl Configure VC-WIN64A --prefix=%GITHUB_WORKSPACE%\bin nmake nmake install_sw # 5. Version prüfen - name: Verify Build run: | bin\bin\openssl.exe version -a bin\bin\openssl.exe list -signature-algorithms | findstr mldsa # 6. Artefakt hochladen - name: Upload Artifact uses: actions/upload-artifact@v4 with: name: openssl-3.6.0-win-x64 path: bin/ retention-days: 30 # ============================================ # Linux x64 Build # ============================================ build-linux: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 - name: Install Dependencies run: | sudo apt-get update sudo apt-get install -y build-essential perl nasm - name: Build OpenSSL run: | cd src ./Configure linux-x86_64 --prefix=$GITHUB_WORKSPACE/linux-build make -j$(nproc) make install - name: Verify Build run: | linux-build/bin/openssl version -a - name: Upload Artifact uses: actions/upload-artifact@v4 with: name: openssl-3.6.0-linux-x64 path: linux-build/ retention-days: 30 ---- ===== Workflow-Struktur erklärt ===== ==== Trigger (on:) ==== on: push: branches: [ main ] # Nur main-Branch paths: - 'src/**' # Nur wenn src/ geändert workflow_dispatch: # Manuell im GitHub UI ==== Jobs ==== jobs: job-name: runs-on: windows-latest # oder ubuntu-latest needs: [andere-jobs] # Abhängigkeiten if: github.event_name == 'push' # Bedingung ==== Schritte ==== steps: - name: Beschreibender Name uses: action/name@v4 # Vorgefertigte Action with: parameter: wert - name: Shell-Befehl run: echo "Hello" shell: bash # oder cmd, pwsh ---- ===== Secrets für private Builds ===== Falls Sie private Builds veröffentlichen: ==== 1. Secret in GitHub erstellen ==== Repository → Settings → Secrets → New secret * ''NUGET_API_KEY'' - Ihr NuGet-Schlüssel * ''AZURE_STORAGE_KEY'' - Für Blob-Upload ==== 2. In Workflow verwenden ==== - name: Publish NuGet run: dotnet nuget push *.nupkg --api-key ${{ secrets.NUGET_API_KEY }} env: NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} ---- ===== Release erstellen ===== Automatisch Release bei Tag: on: push: tags: - 'v*' # z.B. v3.6.0 jobs: release: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 # ... Build-Schritte ... - name: Create Release uses: softprops/action-gh-release@v1 with: files: | openssl-3.6.0-win-x64.zip openssl-3.6.0-linux-x64.tar.gz env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} ---- ===== Matrix-Builds ===== Mehrere Konfigurationen gleichzeitig: jobs: build: runs-on: ${{ matrix.os }} strategy: matrix: os: [windows-latest, ubuntu-latest] include: - os: windows-latest target: VC-WIN64A - os: ubuntu-latest target: linux-x86_64 steps: - name: Configure run: perl Configure ${{ matrix.target }} ---- ===== Workflow manuell starten ===== - Gehen Sie zu "Actions" Tab in GitHub - Wählen Sie den Workflow - Klicken Sie "Run workflow" - Wählen Sie Branch - Klicken Sie "Run workflow" ---- ===== Häufige Probleme ===== ==== "nmake: command not found" ==== Visual Studio Umgebung nicht geladen: - name: Build shell: cmd run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" nmake ==== Build dauert zu lange ==== Cache verwenden: - name: Cache OpenSSL Build uses: actions/cache@v4 with: path: src/ key: openssl-${{ hashFiles('src/VERSION') }} ---- ===== Weiter zu ===== * [[.:azure-devops|Azure DevOps Pipelines]] * [[.:.:start|Zurück zur Übersicht]] ---- //Wolfgang van der Stille @ EMSR DATA d.o.o. - Post-Quantum Cryptography Professional//