Коммит 'Fix app name [ci] [cd]' #9
This file contains hidden or 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: Сборка и публикация приложения | |
run-name: Коммит '${{ github.event.head_commit.message }}' | |
env: | |
GH_TOKEN: ${{ secrets.RELEASE_TOKEN }} | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build: | |
if: "contains(github.event.commits[0].message, '[ci]')" | |
strategy: | |
matrix: | |
include: | |
- os: linux | |
runner: ubuntu-latest | |
file: sd-extract-output | |
- os: windows | |
runner: windows-latest | |
file: sd-extract-output.exe | |
runs-on: ${{ matrix.runner }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Кэш cargo зависимостей | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo/registry | |
~/.cargo/git | |
target | |
key: ${{ matrix.runner }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
- name: Кэш apt зависимостей (Linux) | |
if: matrix.os == 'linux' | |
uses: awalsh128/cache-apt-pkgs-action@latest | |
with: | |
packages: build-essential libssl-dev pkg-config cmake libgtk-3-dev libclang-dev | |
version: 1.0 | |
- name: Сборка бинарного файла | |
run: cargo build --release | |
- name: Сохранение файла в артифакты | |
uses: actions/upload-artifact@v4 | |
with: | |
name: sd-extract-output_${{ matrix.os }} | |
path: target/release/${{ matrix.file }} | |
publish: | |
if: "contains(github.event.commits[0].message, '[cd]')" | |
runs-on: ubuntu-latest | |
needs: [build] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Загрузка бинарного файла linux из артефактов | |
uses: actions/download-artifact@v4 | |
with: | |
name: sd-extract-output_linux | |
path: artifacts | |
- name: Загрузка бинарного файла windows из артефактов | |
uses: actions/download-artifact@v4 | |
with: | |
name: sd-extract-output_windows | |
path: artifacts | |
- name: Получение версии приложения из Cargo.toml | |
id: app_version | |
uses: dante-signal31/rust-app-version@v1.2.0 | |
with: | |
cargo_toml_folder: ./ | |
- name: Переименование файлов | |
run: | | |
mv artifacts/sd-extract-output artifacts/sd-extract-output_v${{ steps.app_version.outputs.app_version }}_linux_x64 && \ | |
mv artifacts/sd-extract-output.exe artifacts/sd-extract-output_v${{ steps.app_version.outputs.app_version }}_windows_x64.exe | |
- name: Публикация файлов | |
run: | | |
gh release create "v${{ steps.app_version.outputs.app_version }}" \ | |
'artifacts/sd-extract-output_v${{ steps.app_version.outputs.app_version }}_linux_x64' \ | |
'artifacts/sd-extract-output_v${{ steps.app_version.outputs.app_version }}_windows_x64.exe' |