Update release.yml (#72) #2
Workflow file for this run
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: Build and Release | |
on: | |
push: | |
tags: | |
- 'v*' # Triggers the workflow when a tag starting with 'v' is pushed | |
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 | |
cd src && make install DESTDIR=../installation | |
- 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: 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: Download build artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: HELLO-${{ matrix.os }}-${{ matrix.arch }} | |
path: ./artifacts | |
- name: List files in artifacts directory | |
run: | | |
echo "Listing files in ./artifacts:" | |
ls -l ./artifacts | |
- 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 | |
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 }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |