Skip to content

Fix cmake.yml

Fix cmake.yml #47

Workflow file for this run

name: CMake
on:
push:
branches: [ "main" ]
tags:
- '*'
pull_request:
branches: [ "main" ]
env:
BUILD_TYPE: Release
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, windows-latest, macOS-11]
include:
- os: ubuntu-20.04
artifact_suffix: ""
- os: windows-latest
artifact_suffix: ".exe"
- os: macOS-11
artifact_suffix: ""
steps:
- uses: actions/checkout@v4
- name: Configure CMake
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
- name: Create .deb package (Ubuntu)
if: matrix.os == 'ubuntu-20.04'
run: |
cd build
cmake --build . --target package
- name: Store artifacts
uses: actions/upload-artifact@v4
with:
name: secure_password_generator-${{ matrix.os }}
path: |
${{github.workspace}}/build/secure_password_generator${{ matrix.artifact_suffix }}
${{github.workspace}}/build/${{env.BUILD_TYPE}}/secure_password_generator${{ matrix.artifact_suffix }}
${{github.workspace}}/build/*.deb
retention-days: 5 # Add retention period for artifacts
release:
needs: build
runs-on: ubuntu-latest
permissions:
contents: write # Explicitly declare required permissions
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true # Merge all artifacts into one directory
- name: Prepare release assets
run: |
# Ubuntu
chmod +x artifacts/secure_password_generator || true
tar czvf secure_password_generator-ubuntu-x86_64.tar.gz -C artifacts secure_password_generator || true
# Windows
zip -j secure_password_generator-windows.zip artifacts/Release/secure_password_generator.exe || true
# macOS
chmod +x artifacts/secure_password_generator || true
tar czvf secure_password_generator-macOS.tar.gz -C artifacts secure_password_generator || true
- name: Create Release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Use default token
with:
files: |
secure_password_generator-ubuntu-x86_64.tar.gz
artifacts/*.deb
secure_password_generator-windows.zip
secure_password_generator-macOS.tar.gz
draft: false
prerelease: false
fail_on_unmatched_files: false