Update build-release.yml #90
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 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: Get release info | |
id: release_info | |
run: | | |
if gh release view v${{ env.VERSION }}; then | |
echo "Release exists" | |
echo "release_exists=true" >> $GITHUB_ENV | |
else | |
echo "release_exists=false" >> $GITHUB_ENV | |
fi | |
env: | |
GH_TOKEN: ${{ github.GITHUB_TOKEN }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- 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: ${{ github.GITHUB_TOKEN }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create new Git tag | |
run: | | |
git tag v${{ env.VERSION }} | |
git push origin v${{ env.VERSION }} | |
env: | |
GH_TOKEN: ${{ github.GITHUB_TOKEN }} | |
GITHUB_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 }} |