Update release.yml #8
This file contains 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
name: C CI and Release | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
jobs: | |
build-and-release: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Cache dependencies | |
uses: actions/cache@v3 | |
with: | |
path: | | |
/var/cache/apt/archives | |
key: ${{ runner.os }}-apt-${{ hashFiles('**/Makefile') }} | |
restore-keys: | | |
${{ runner.os }}-apt- | |
- name: Install dependencies | |
run: | | |
sudo apt-get update && sudo apt-get upgrade -y | |
sudo apt-get install -y build-essential libssl-dev oathtool liboath0 liboath-dev && sudo apt-get update | |
- name: Clean previous build | |
run: make clean | |
continue-on-error: true | |
- name: Build project | |
run: make | |
- name: Run tests | |
run: make test | |
continue-on-error: true | |
- name: Check for build artifacts | |
id: check_artifacts | |
run: | | |
if [ -f "securepass" ]; then | |
echo "::set-output name=artifact_exists::true" | |
else | |
echo "::set-output name=artifact_exists::false" | |
fi | |
- name: Create Release | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && steps.check_artifacts.outputs.artifact_exists == 'true' | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.SECPASSWD_TOKEN }} | |
with: | |
tag_name: v${{ github.run_number }} | |
release_name: Release ${{ github.run_number }} | |
draft: false | |
prerelease: false | |
- name: Upload Release Asset | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && steps.check_artifacts.outputs.artifact_exists == 'true' | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.SECPASSWD_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./securepass | |
asset_name: securepass | |
asset_content_type: application/octet-stream | |
- name: Notify on failure | |
if: failure() | |
run: | | |
echo "Build or tests failed. Please check the logs for more information." | |
exit 1 |