Skip to content

clean and improve main #93

clean and improve main

clean and improve main #93

Workflow file for this run

name: Build and Release Salam
on:
push:
branches:
- main
jobs:
build-linux:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install dependencies
run: sudo apt-get install build-essential
- name: "GCC Version"
run: |
gcc --version
- name: Build salam for Linux
run: |
cd src
make run
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: salam-linux
path: src/salam
build-macos:
runs-on: macos-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: "GCC Version"
run: |
gcc --version
- name: Build salam for macOS
run: |
cd src
make run
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: salam-macos
path: src/salam
build-windows:
runs-on: windows-latest
defaults:
run:
shell: bash
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: "GCC Version"
run: |
gcc --version
- name: Build salam.exe for Windows
run: |
cd src
build-windows.bat
shell: cmd
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: salam-windows
path: src/salam.exe
create-release:
runs-on: ubuntu-latest
needs: [build-linux, build-macos, build-windows]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Read version from VERSION file
id: get_version
run: |
VERSION=$(cat VERSION | sed 's/^[ \t]*//;s/[ \t]*$//')
echo "VERSION=${VERSION}" >> $GITHUB_ENV
echo "Salam version: ${VERSION}"
- name: Download Linux artifact
uses: actions/download-artifact@v4
with:
name: salam-linux
path: ./release
- name: Rename Linux binary to avoid conflict
run: |
mv ./release/salam ./release/salam-linux
- name: Download macOS artifact
uses: actions/download-artifact@v4
with:
name: salam-macos
path: ./release
- name: Rename macOS binary to avoid conflict
run: |
mv ./release/salam ./release/salam-mac
- name: Download Windows artifact
uses: actions/download-artifact@v4
with:
name: salam-windows
path: ./release
- name: Rename Window binary
run: |
mv ./release/salam.exe ./release/salam-windows.exe
- name: Post Linux release file to SERVER_VERSIONS_API
run: |
curl -X POST "${{ secrets.SERVER_VERSIONS_API }}" \
-F "file=@./release/salam-linux" \
-F "version=${{ env.VERSION }}" \
-F "date=$(date +'%Y-%m-%d')" \
-F "time=$(date +'%H:%M:%S')" \
-F "key='${{ secrets.SERVER_VERSIONS_KEY }}'" \
-F "platform=linux"
- name: Post macOS release file to SERVER_VERSIONS_API
run: |
curl -X POST "${{ secrets.SERVER_VERSIONS_API }}" \
-F "file=@./release/salam-mac" \
-F "version=${{ env.VERSION }}" \
-F "date=$(date +'%Y-%m-%d')" \
-F "time=$(date +'%H:%M:%S')" \
-F "key='${{ secrets.SERVER_VERSIONS_KEY }}'" \
-F "platform=macos"
- name: Post Windows release file to SERVER_VERSIONS_API
run: |
curl -X POST "${{ secrets.SERVER_VERSIONS_API }}" \
-F "file=@./release/salam-windows.exe" \
-F "version=${{ env.VERSION }}" \
-F "date=$(date +'%Y-%m-%d')" \
-F "time=$(date +'%H:%M:%S')" \
-F "key='${{ secrets.SERVER_VERSIONS_KEY }}'" \
-F "platform=windows"
- name: Set up GitHub CLI
run: sudo apt-get install gh -y
- name: Authenticate GitHub CLI
run: gh auth login --with-token <<< ${{ secrets.GITHUB_TOKEN }}
- name: Check if release exists
id: check_release
run: |
if gh release view v${{ env.VERSION }} > /dev/null 2>&1; then
echo "Release exists"
echo "release_exists=true" >> $GITHUB_ENV
else
echo "Release does not exist"
echo "release_exists=false" >> $GITHUB_ENV
fi
- name: Delete existing release and tag if found
if: env.release_exists == 'true'
run: |
gh release delete v${{ env.VERSION }} --yes
git tag -d v${{ env.VERSION }}
git push origin :refs/tags/v${{ env.VERSION }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create new Git tag
run: |
git tag v${{ env.VERSION }}
git push origin v${{ env.VERSION }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create new GitHub Release and Tag
uses: softprops/action-gh-release@v2
with:
tag_name: "v${{ env.VERSION }}"
name: "Salam Release v${{ env.VERSION }}"
body: "This release includes the latest build for Linux, macOS, and Windows."
files: |
release/salam-linux
release/salam-mac
release/salam-windows.exe
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}