Build and Release #24
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: | |
workflow_dispatch: | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
target: | |
- x86_64-pc-windows-gnu | |
# - aarch64-pc-windows-gnu | |
# - x86_64-unknown-linux-gnu | |
# - x86_64-apple-darwin | |
steps: | |
- name: "Checkout" | |
uses: actions/checkout@v4 | |
- name: "Extract Package Version" | |
id: cargo-version | |
run: | | |
version=v$(grep -oP 'version\s*=\s*"\K[0-9]+\.[0-9]+\.[0-9]+' dygma-layer-switcher/Cargo.toml | head -n 1) | |
echo "PACKAGE_VERSION=$version" | |
echo "PACKAGE_VERSION=$version" >> $GITHUB_ENV | |
- name: "Set up Rust" | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
toolchain: stable | |
targets: ${{ matrix.target }} | |
- name: "Update Package List" | |
run: sudo apt-get update -y | |
- name: "Install Dependencies" | |
run: sudo apt-get install -y mingw-w64 libudev-dev zip wine64 | |
- name: "Build" | |
run: cargo build --release --target ${{ matrix.target }} | |
- name: "Zip" | |
run: | | |
if [[ "${{ matrix.target }}" == *"windows"* ]]; then | |
executable_name="dygma-layer-switcher.exe" | |
cp target/${{ matrix.target }}/release/$executable_name . | |
mv $executable_name "Dygma Layer Switcher.exe" | |
zip dls-${{ env.PACKAGE_VERSION }}-${{ matrix.target }}.zip "Dygma Layer Switcher.exe" | |
else | |
executable_name="dygma-layer-switcher" | |
cp target/${{ matrix.target }}/release/$executable_name . | |
mv $executable_name "Dygma Layer Switcher" | |
zip dls-${{ env.PACKAGE_VERSION }}-${{ matrix.target }}.zip "Dygma Layer Switcher" | |
fi | |
env: | |
PACKAGE_VERSION: ${{ env.PACKAGE_VERSION }} | |
- name: "Upload Artifacts" | |
uses: actions/upload-artifact@v4 | |
with: | |
path: dls-${{ env.PACKAGE_VERSION }}-${{ matrix.target }}.zip | |
name: dls-${{ env.PACKAGE_VERSION }}-${{ matrix.target }}.zip | |
release: | |
name: Create Release | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: "Checkout" | |
uses: actions/checkout@v4 | |
- name: "Extract Package Version" | |
id: cargo-version | |
run: | | |
version=v$(grep -oP 'version\s*=\s*"\K[0-9]+\.[0-9]+\.[0-9]+' dygma-layer-switcher/Cargo.toml | head -n 1) | |
echo "PACKAGE_VERSION=$version" | |
echo "PACKAGE_VERSION=$version" >> $GITHUB_ENV | |
- name: "Download Artifacts" | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: '**/dls-*.zip' | |
merge-multiple: true | |
path: . | |
- name: "Create Git Tag" | |
run: | | |
git config --local user.name "GitHub Action" | |
git config --local user.email "[email protected]" | |
git tag -a ${{ env.PACKAGE_VERSION }} -m "${{ env.PACKAGE_VERSION }}" | |
git push origin ${{ env.PACKAGE_VERSION }} | |
- name: "Create GitHub Release" | |
uses: softprops/action-gh-release@v2 | |
with: | |
tag_name: ${{ env.PACKAGE_VERSION }} | |
release_name: ${{ env.PACKAGE_VERSION }} | |
files: | | |
dls-${{ env.PACKAGE_VERSION }}-*.zip |