Skip to content

Commit

Permalink
Update release.yml (#75)
Browse files Browse the repository at this point in the history
More substantial adjustments to the other workflow are necessary, we're reverting back
  • Loading branch information
DanielOlson authored Dec 10, 2024
1 parent bde7fa2 commit 1fdcf58
Showing 1 changed file with 19 additions and 101 deletions.
120 changes: 19 additions & 101 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,117 +3,35 @@ name: Build and Release
on:
push:
tags:
- 'v*' # Triggers the workflow when a tag starting with 'v' is pushed
- 'v*.*.*' # Trigger only on version tags
pull_request:
tags:
- 'v*.*.*' # Trigger only on version tags

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest] # build for ubuntu and mac
arch: [x64, arm64] # x64 and arm
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up build environment
run: |
if [ ${{ matrix.os }} == 'ubuntu-latest' ]; then
sudo apt-get update
sudo apt-get install -y autoconf gcc make cmake
elif [ ${{ matrix.os }} == 'macos-latest' ]; then
brew install autoconf gcc make cmake
fi
- name: Build
run: |
cmake .
make
mkdir -p installation/usr/local/bin
make install DESTDIR=installation
runs-on: ubuntu-latest

- name: Extract version from github.ref
id: extract_version
run: echo "::set-output name=version::$(echo ${GITHUB_REF#refs/tags/})"

- name: Create tar.gz archive
run: |
cd installation/usr/local/bin
tar -czvf ../../../HELLO-${{ steps.extract_version.outputs.version }}.${{ matrix.os }}.${{ matrix.arch }}.tar.gz hello
- name: Archive build artifacts
uses: actions/upload-artifact@v4
with:
name: HELLO-${{ matrix.os }}-${{ matrix.arch }}
path: installation/HELLO-${{ steps.extract_version.outputs.version }}.${{ matrix.os }}.${{ matrix.arch }}.tar.gz
if-no-files-found: error

release:
needs: build
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
arch: [x64, arm64]
steps:
- uses: actions/checkout@v3
- name: Checkout code
uses: actions/checkout@v2

- name: Check if release exists
id: check_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref_name }}
run: |
if gh release view "$tag" --repo="$GITHUB_REPOSITORY" > /dev/null 2>&1; then
echo "release_exists=true" >> $GITHUB_ENV
else
echo "release_exists=false" >> $GITHUB_ENV
fi
- name: Create release
if: env.release_exists == 'false'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref_name }}
run: |
gh release create "$tag" \
--repo="$GITHUB_REPOSITORY" \
--title="${GITHUB_REPOSITORY#*/} ${tag#v}" \
--generate-notes
- name: Configure CMake
run: cmake -S . -B build

- name: Download build artifacts
uses: actions/download-artifact@v4
with:
pattern: HELLO-${{ matrix.os }}-${{ matrix.arch }}
path: ./artifacts
- name: Build with CMake
run: cmake --build build --config Release

- name: List files in artifacts directory
- name: Create zip archive of binaries
run: |
echo "Listing files in ./artifacts:"
ls -l ./artifacts
mkdir build_output
cp build/ultra build_output/
zip -r binaries_${{ github.ref_name }}.zip build_output/
shell: bash

- name: Upload Release Assets
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: ./artifacts/HELLO-${{ matrix.os }}-${{ matrix.arch }}/*
tag_name: ${{ steps.extract_version.outputs.version }}
name: Release ${{ steps.extract_version.outputs.version }}
prerelease: false
draft: false
token: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Python
uses: actions/setup-python@v4
- name: Upload binaries to GitHub Release
uses: softprops/action-gh-release@v1
with:
python-version: '3.x' # Specify the version of Python to use

- name: Install dependencies
run: python -m pip install --upgrade pip && pip install requests

- name: Run Python script
run: |
python .github/workflows/update_release_table.py ${{ github.ref_name }}
files: binaries_${{ github.ref_name }}.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 1fdcf58

Please sign in to comment.