diff --git a/.github/workflows/build_release.yml b/.github/workflows/build_release.yml new file mode 100644 index 0000000..f898156 --- /dev/null +++ b/.github/workflows/build_release.yml @@ -0,0 +1,108 @@ +name: Build and Release + +on: + push: + tags: + - "[0-9]+.[0-9]+.[0-9]+" + +permissions: + contents: write + +jobs: + build-and-upload: + name: Build and upload + runs-on: ${{ matrix.os }} + + strategy: + matrix: + include: + - build: linux + os: ubuntu-latest + target: x86_64-unknown-linux-musl + - build: macos + os: macos-latest + target: x86_64-apple-darwin + - build: windows + os: windows-latest + target: x86_64-pc-windows-msvc + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Get release version from tag + shell: bash + run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV + + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + with: + targets: ${{ matrix.target }} + components: clippy + + - name: Cache dependencies + uses: actions/cache@v3 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + + - name: Run tests + uses: actions-rs/cargo@v1 + with: + command: test + args: --verbose --target ${{ matrix.target }} + + - name: Run clippy + uses: actions-rs/cargo@v1 + with: + command: clippy + args: --target ${{ matrix.target }} -- -D warnings + + - name: Build release binary + uses: actions-rs/cargo@v1 + with: + use-cross: true + command: build + args: --verbose --release --target ${{ matrix.target }} + + - name: Build archive + shell: bash + run: | + # Replace with the name of your binary + binary_name="chromascope" + + dirname="$binary_name-${{ env.VERSION }}-${{ matrix.target }}" + mkdir "$dirname" + + if [ "${{ matrix.os }}" = "windows-latest" ]; then + mv "target/${{ matrix.target }}/release/$binary_name.exe" "$dirname" + 7z a "$dirname.zip" "$dirname" + echo "ASSET=$dirname.zip" >> $GITHUB_ENV + else + mv "target/${{ matrix.target }}/release/$binary_name" "$dirname" + tar -czf "$dirname.tar.gz" "$dirname" + echo "ASSET=$dirname.tar.gz" >> $GITHUB_ENV + fi + + - name: Generate changelog + id: changelog + uses: metcalfc/changelog-generator@v4.0.1 + with: + myToken: ${{ secrets.GITHUB_TOKEN }} + + - name: Release + uses: softprops/action-gh-release@v1 + with: + files: ${{ env.ASSET }} + body: ${{ steps.changelog.outputs.changelog }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Upload artifact + uses: actions/upload-artifact@v3 + with: + name: ${{ matrix.target }} + path: ${{ env.ASSET }} \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 2c76c60..0436f21 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,7 +8,7 @@ //! //! The application is designed to run on Windows systems, and the `#![windows_subsystem = "windows"]` directive is included to ensure proper integration with the Windows environment. -#![windows_subsystem = "windows"] +#![cfg_attr(target_os = "windows", windows_subsystem = "windows")] mod gui; mod parser;