release #103 #370
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: | |
branches: [main, dev] | |
pull_request: | |
branches: [main] | |
jobs: | |
build: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
include: | |
- os: ubuntu-latest | |
artifact_extension: tar.gz | |
- os: macos-latest | |
artifact_extension: zip | |
- os: windows-latest | |
artifact_extension: zip | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
# Ubuntu Section | |
- name: Install dependencies (Ubuntu) | |
if: matrix.os == 'ubuntu-latest' | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y ninja-build \ | |
qt6-base-dev qt6-tools-dev qt6-tools-dev-tools \ | |
qt6-l10n-tools libgl1-mesa-dev libglu1-mesa-dev rsync | |
- name: Configure CMake (Ubuntu) | |
if: matrix.os == 'ubuntu-latest' | |
run: | | |
cmake -B "${{ github.workspace }}/build" \ | |
-DCMAKE_BUILD_TYPE=Release \ | |
-G "Ninja" \ | |
-S "${{ github.workspace }}" | |
- name: Build Notepad-- (Ubuntu) | |
if: matrix.os == 'ubuntu-latest' | |
run: cmake --build "${{ github.workspace }}/build" --config Release | |
- name: Package Notepad-- (Ubuntu) | |
if: matrix.os == 'ubuntu-latest' | |
run: | | |
BUILD_DIR="${{ github.workspace }}/build" | |
OUTPUT_DIR="${{ github.workspace }}/artifacts" | |
mkdir -p $OUTPUT_DIR | |
tar -czvf $OUTPUT_DIR/Notepad--_ubuntu.tar.gz -C $BUILD_DIR . | |
- name: Upload Ubuntu Artifact | |
if: matrix.os == 'ubuntu-latest' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: Notepad--_ubuntu | |
path: "${{ github.workspace }}/artifacts/Notepad--_ubuntu.tar.gz" | |
# macOS Section | |
- name: Install dependencies (macOS) | |
if: matrix.os == 'macos-latest' | |
run: | | |
brew install ninja qt | |
- name: Configure CMake (macOS) | |
if: matrix.os == 'macos-latest' | |
run: | | |
cmake -B "${{ github.workspace }}/build" \ | |
-DCMAKE_BUILD_TYPE=Release \ | |
-G "Ninja" \ | |
-S "${{ github.workspace }}" | |
- name: Build Notepad-- (macOS) | |
if: matrix.os == 'macos-latest' | |
run: cmake --build "${{ github.workspace }}/build" --config Release | |
- name: Package Notepad-- (macOS) | |
if: matrix.os == 'macos-latest' | |
run: | | |
BUILD_DIR="${{ github.workspace }}/build" | |
OUTPUT_DIR="${{ github.workspace }}/artifacts" | |
mkdir -p $OUTPUT_DIR | |
zip -r $OUTPUT_DIR/Notepad--_macos.zip $BUILD_DIR | |
- name: Upload macOS Artifact | |
if: matrix.os == 'macos-latest' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: Notepad--_macos | |
path: "${{ github.workspace }}/artifacts/Notepad--_macos.zip" | |
# Windows Section | |
- name: Install dependencies (Windows) | |
if: matrix.os == 'windows-latest' | |
run: | | |
choco install ninja -y | |
choco install cmake --installargs 'ADD_CMAKE_TO_PATH=System' -y | |
choco install mingw -y | |
shell: cmd | |
- name: Install Qt (Windows) | |
if: matrix.os == 'windows-latest' | |
uses: jurplel/install-qt-action@v4 | |
with: | |
version: '6.5.3' | |
host: 'windows' | |
target: 'desktop' | |
arch: 'win64_mingw' | |
- name: Configure CMake (Windows) | |
if: matrix.os == 'windows-latest' | |
run: | | |
cmake -B "${{ github.workspace }}\\build" ^ | |
-DCMAKE_BUILD_TYPE=Release ^ | |
-G Ninja ^ | |
-DCMAKE_PREFIX_PATH=D:\\a\\Notepad--\\Qt\\6.5.3\\mingw_64 ^ | |
-S "${{ github.workspace }}" | |
shell: cmd | |
- name: Build Notepad-- (Windows) | |
if: matrix.os == 'windows-latest' | |
run: cmake --build "${{ github.workspace }}\\build" --config Release | |
shell: cmd | |
- name: Package Notepad-- (Windows) | |
if: matrix.os == 'windows-latest' | |
run: | | |
$BUILD_DIR="${{ github.workspace }}\\build" | |
$OUTPUT_DIR="${{ github.workspace }}\\artifacts" | |
mkdir $OUTPUT_DIR | |
Compress-Archive -Path "$BUILD_DIR\\*" -DestinationPath "$OUTPUT_DIR\\Notepad--_windows.zip" | |
shell: pwsh | |
- name: Upload Windows Artifact | |
if: matrix.os == 'windows-latest' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: Notepad--_windows | |
path: "${{ github.workspace }}\\artifacts\\Notepad--_windows.zip" | |
release: | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Download Artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: artifacts | |
- name: Generate Tag Name | |
id: tag_name | |
run: echo "RELEASE_TAG=release-$(date +%Y%m%d%H%M%S)" >> $GITHUB_ENV | |
- name: Create GitHub Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ env.RELEASE_TAG }} | |
release_name: Notepad-- Release | |
draft: false | |
prerelease: false | |
- name: Upload Artifacts to Release | |
run: | | |
for file in $(find artifacts -type f); do | |
gh release upload ${{ env.RELEASE_TAG }} "$file" | |
done | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |