From bca6d3abbbcfc35bbac4943873807b56cb6e23d8 Mon Sep 17 00:00:00 2001 From: w1nst0n Date: Sun, 28 Aug 2022 23:05:15 +0200 Subject: [PATCH] [CI] Github Actions workflows overhaul (+ add auto `dev-build` release) - Big refactoring using the new reusable workflow feature - Better use of caching - Replace lld linker on MacOS/Linux by a better one: https://github.com/rui314/mold - Automatically create a `dev-build` release whenever a commit changing the software code lands into the main branch - Replace unmaintained Github Action `actions-rs/toolchain` by `dtolnay/rust-toolchain` - Use the new `automatically generated release notes` feature from Github --- .cargo/config | 14 ++- .github/release.yml | 17 ++++ .github/workflows/build_artifacts.yaml | 71 -------------- .github/workflows/build_artifacts.yml | 67 +++++++++++++ .github/workflows/ci.yml | 128 ++++++++----------------- .github/workflows/release.yml | 105 ++++++++------------ 6 files changed, 169 insertions(+), 233 deletions(-) create mode 100644 .github/release.yml delete mode 100644 .github/workflows/build_artifacts.yaml create mode 100644 .github/workflows/build_artifacts.yml diff --git a/.cargo/config b/.cargo/config index ecd4a93..6ab5299 100644 --- a/.cargo/config +++ b/.cargo/config @@ -1,12 +1,10 @@ -[target.x86_64-pc-windows-gnu] -linker = "/usr/bin/x86_64-w64-mingw32-gcc" -ar = "/usr/bin/x86_64-w64-mingw32-ar" - -[target.i686-pc-windows-gnu] -linker = "/usr/bin/i686-w64-mingw32-gcc" - [target.x86_64-pc-windows-msvc] rustflags = ["-C", "target-feature=+crt-static"] [target.x86_64-unknown-linux-gnu] -rustflags = ["-C", "link-arg=-fuse-ld=lld"] +linker = "clang" +rustflags = ["-C", "link-arg=-fuse-ld=/usr/local/bin/mold"] + +[target.aarch64-apple-darwin] +linker = "clang" +rustflags = ["-C", "link-arg=-fuse-ld=/usr/local/bin/mold"] \ No newline at end of file diff --git a/.github/release.yml b/.github/release.yml new file mode 100644 index 0000000..d3400e8 --- /dev/null +++ b/.github/release.yml @@ -0,0 +1,17 @@ +changelog: + exclude: + labels: + - package::documentation + - package::addition + - package::breakage + - package::bootloop + categories: + - title: Added + labels: + - feature + - title: Changed + labels: + - enhancement + - title: Fixed + labels: + - bug diff --git a/.github/workflows/build_artifacts.yaml b/.github/workflows/build_artifacts.yaml deleted file mode 100644 index 99be69e..0000000 --- a/.github/workflows/build_artifacts.yaml +++ /dev/null @@ -1,71 +0,0 @@ -name: Build artifacts -on: workflow_dispatch - -jobs: - build: - name: Building ${{ matrix.build_target }} [${{ matrix.graphics }}] [${{ matrix.update_feature }}] - runs-on: ${{ matrix.os }} - strategy: - matrix: - build_target: [linux, macos, windows] - graphics: [glow, wgpu] - update_feature: [self-update, no-self-update] - exclude: - - build_target: windows - update_feature: no-self-update - include: - - build_target: linux - os: ubuntu-latest - - build_target: macos - os: macos-latest - - build_target: windows - os: windows-latest - - graphics: glow - renderer: "-opengl" - - graphics: wgpu - renderer: '' # Vulkan but we don't want this in the binary filename - - update_feature: self-update - update_name: '' # we don't want this in the binary filename - - update_feature: no-self-update - update_name: "-noseflupdate" - steps: - - name: Install Rust toolchain - uses: actions-rs/toolchain@v1 - with: - toolchain: nightly - override: true - target: ${{ matrix.target }} - profile: minimal - - name: Install Linux dependencies - if: matrix.os == 'ubuntu-latest' - run: | - sudo apt-get -qq update - sudo apt-get install -y libxkbcommon-dev lld - - uses: actions/checkout@v2 - - name: Cargo build - uses: actions-rs/cargo@v1 - with: - command: build - args: --release --no-default-features --features ${{ matrix.graphics }},${{ matrix.update_feature }} - - name: Renaming binaries [Windows] - if: matrix.os == 'windows-latest' - run: mv target/release/uad_gui.exe target/release/uad_gui-${{ matrix.build_target }}${{ matrix.renderer }}.exe - - name: Renaming binaries [Others] - if: matrix.os != 'windows-latest' - run: mv target/release/uad_gui target/release/uad_gui${{ matrix.update_name }}-${{ matrix.build_target }}${{ matrix.renderer }} - - name: Tarball Linux binary - if: matrix.os == 'ubuntu-latest' - run: | - cd target/release/ - tar --remove-files -czf uad_gui${{ matrix.update_name }}-${{ matrix.build_target }}${{ matrix.renderer }}{.tar.gz,} - - name: Tarball MacOS binaries # --remove-files is not available on bsd tar - if: matrix.os == 'macos-latest' - run: | - brew install gnu-tar - cd target/release/ - gtar --remove-files -czf uad_gui${{ matrix.update_name }}-${{ matrix.build_target }}${{ matrix.renderer }}{.tar.gz,} - - name: Upload artifact - uses: actions/upload-artifact@v2 - with: - name: uad_gui${{ matrix.update_name }}-${{ matrix.build_target }}${{ matrix.renderer }} - path: target/release/uad_gui-* \ No newline at end of file diff --git a/.github/workflows/build_artifacts.yml b/.github/workflows/build_artifacts.yml new file mode 100644 index 0000000..79beed5 --- /dev/null +++ b/.github/workflows/build_artifacts.yml @@ -0,0 +1,67 @@ +name: Build artifacts +on: + workflow_dispatch: + workflow_call: + +jobs: + build: + name: Building ${{ matrix.build_target }} [${{ matrix.graphics }}] [${{ matrix.update_feature }}] + runs-on: ${{ matrix.os }} + strategy: + matrix: + build_target: [linux, macos, windows] + graphics: [glow, wgpu] + update_feature: [self-update, no-self-update] + exclude: + - build_target: windows + update_feature: no-self-update + include: + - build_target: linux + os: ubuntu-latest + - build_target: macos + os: macos-latest + - build_target: windows + os: windows-latest + - graphics: glow + renderer: "-opengl" + - graphics: wgpu + renderer: '' # Vulkan but we don't want this in the binary filename + - update_feature: self-update + update_name: '' # we don't want this in the binary filename + - update_feature: no-self-update + update_name: "-noseflupdate" + steps: + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@nightly + - uses: rui314/setup-mold@v1 # faster linker + with: + make-default: false + - uses: actions/cache@v3 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target + key: ${{ runner.os }}-release-${{ hashFiles('**/Cargo.lock') }} + restore-keys: ${{ runner.OS }}-release- + if: matrix.os == 'ubuntu-latest' + - name: Building + run: cargo build --release --no-default-features --features ${{ matrix.graphics }},${{ matrix.update_feature }} + - name: Creating ./bin directory + run: mkdir -p bin + - name: Renaming binaries [Windows] + if: matrix.os == 'windows-latest' + run: mv target/release/uad_gui.exe bin/uad_gui-${{ matrix.build_target }}${{ matrix.renderer }}.exe + - name: Renaming binaries [Others] + if: matrix.os != 'windows-latest' + run: mv target/release/uad_gui bin/uad_gui${{ matrix.update_name }}-${{ matrix.build_target }}${{ matrix.renderer }} + - name: Tarball Linux/MacOS binary + if: matrix.os != 'ubuntu-latest' + run: tar -czf bin/uad_gui${{ matrix.update_name }}-${{ matrix.build_target }}${{ matrix.renderer }}{.tar.gz,} + - name: Upload artifacts + uses: actions/upload-artifact@v3 + with: + name: uad_gui${{ matrix.update_name }}-${{ matrix.build_target }}${{ matrix.renderer }} + path: bin/uad_gui-* \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 21ea6f9..4be1bbd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,6 +6,8 @@ on: - 'Cargo.lock' - 'Cargo.toml' - '**.json' + tags-ignore: + - '*' pull_request: paths: - '**.rs' @@ -14,96 +16,46 @@ on: - '**.json' jobs: - check: - name: Check - runs-on: ubuntu-latest + lint: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macOS-latest] + lint: [check, test, clippy, fmt] + exclude: # https://github.com/community/community/discussions/7835 + - os: windows-latest + lint: clippy + - os: windows-latest + lint: fmt + - os: macOS-latest + lint: clippy + - os: macOS-latest + lint: fmt + include: + - lint: check + args: " --all-features" + - lint: test + args: '' + - lint: clippy + args: " --all --all-features -- -D warnings" + - lint: fmt + args: " --all -- --check" steps: - - uses: actions/checkout@v2 - - name: Install dependencies - run: | - sudo apt -qq update - sudo apt install -y lld - - uses: actions/cache@v2 + - uses: actions/checkout@v3 + - uses: rui314/setup-mold@v1 # faster linker + with: + make-default: false + - uses: actions/cache@v3 with: path: | - ~/.cargo/registry - ~/.cargo/git + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ target - key: ${{ runner.os }}-check-${{ hashFiles('**/Cargo.lock') }} - - uses: actions-rs/toolchain@v1 + key: ${{ runner.os }}-${{ matrix.lint }}-${{ hashFiles('**/Cargo.lock') }} + restore-keys: ${{ runner.OS }}-${{ matrix.lint }}- + - uses: dtolnay/rust-toolchain@nightly with: - profile: minimal - toolchain: nightly - override: true - - uses: actions-rs/cargo@v1 - with: - command: check - args: --all-features - - test: - name: Test Suite - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Install dependencies - run: | - sudo apt -qq update - sudo apt install -y libxkbcommon-dev lld - - uses: actions/cache@v2 - with: - path: | - ~/.cargo/registry - ~/.cargo/git - target - key: ${{ runner.os }}-test-${{ hashFiles('**/Cargo.lock') }} - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: nightly - override: true - - uses: actions-rs/cargo@v1 - with: - command: test - - fmt: - name: Rustfmt - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: nightly - override: true - - run: rustup component add rustfmt - - uses: actions-rs/cargo@v1 - with: - command: fmt - args: --all -- --check - - clippy: - name: Clippy - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Install dependencies - run: | - sudo apt -qq update - sudo apt install -y lld - - uses: actions/cache@v2 - with: - path: | - ~/.cargo/registry - ~/.cargo/git - target - key: ${{ runner.os }}-clippy-${{ hashFiles('**/Cargo.lock') }} - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: nightly - override: true - - run: rustup component add clippy - - uses: actions-rs/cargo@v1 - with: - command: clippy - args: --all --all-features -- -D warnings + components: clippy,rustfmt + - run: cargo ${{ matrix.lint }}${{ matrix.args }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 52707ce..cfe3781 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,77 +1,50 @@ -name: Build +name: Build and release + on: push: - tags: - - '*' + branches: + - main + paths: + - '**.rs' + - 'Cargo.lock' + - 'Cargo.toml' + tags-ignore: + - dev-build + +env: + dev_tag: dev-build jobs: - publish: - name: Building ${{ matrix.build_target }} [${{ matrix.graphics }}] - runs-on: ${{ matrix.os }} - strategy: - matrix: - build_target: [linux, macos, windows] - graphics: [glow, wgpu] - update_feature: [self-update, no-self-update] - exclude: - - build_target: windows - update_feature: no-self-update - include: - - build_target: linux - os: ubuntu-latest - - build_target: macos - os: macos-latest - - build_target: windows - os: windows-latest - - graphics: glow - renderer: "-opengl" - - graphics: wgpu - renderer: '' # Vulkan but we don't want this in the binary filename - - update_feature: self-update - update_name: '' # we don't want this in the binary filename - - update_feature: no-self-update - update_name: "-noselfupdate" + build: + uses: ./.github/workflows/build_artifacts.yml + release: + runs-on: ubuntu-latest + needs: build steps: - - name: Install Rust toolchain - uses: actions-rs/toolchain@v1 + - uses: actions/checkout@v3 + - name: Downloads artifacts + uses: actions/download-artifact@v3 with: - toolchain: nightly - override: true - target: ${{ matrix.target }} - profile: minimal - - name: Install Linux dependencies - if: matrix.os == 'ubuntu-latest' - run: | - sudo apt-get -qq update - sudo apt-get install -y libxkbcommon-dev lld - - uses: actions/checkout@v2 - - name: Cargo build - uses: actions-rs/cargo@v1 - with: - command: build - args: --release --no-default-features --features ${{ matrix.graphics }},${{ matrix.update_feature }} - - name: Renaming binaries [Windows] - if: matrix.os == 'windows-latest' - run: mv target/release/uad_gui.exe target/release/uad_gui-${{ matrix.build_target }}${{ matrix.renderer }}.exe - - name: Renaming binaries [Others] - if: matrix.os != 'windows-latest' - run: mv target/release/uad_gui target/release/uad_gui${{ matrix.update_name }}-${{ matrix.build_target }}${{ matrix.renderer }} - - name: Tarball Linux binary - if: matrix.os == 'ubuntu-latest' - run: | - cd target/release/ - tar --remove-files -czf uad_gui${{ matrix.update_name }}-${{ matrix.build_target }}${{ matrix.renderer }}{.tar.gz,} - - name: Tarball MacOS binaries # --remove-files is not available on bsd tar - if: matrix.os == 'macos-latest' - run: | - brew install gnu-tar - cd target/release/ - gtar --remove-files -czf uad_gui${{ matrix.update_name }}-${{ matrix.build_target }}${{ matrix.renderer }}{.tar.gz,} + path: bin - name: Create pre-release + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') uses: softprops/action-gh-release@v1 with: body_path: ${{ github.workspace }}/CHANGELOG.md - files: target/release/uad_gui-* + files: bin/*/uad_gui-* prerelease: true - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + - name: Update dev-build tag + if: ${{ github.event_name == 'push' }} + run: | + git tag -d ${{ env.dev_tag }} || true + git push origin :refs/tags/${{ env.dev_tag }} || true + git tag ${{ env.dev_tag }} + git push origin ${{ env.dev_tag }} + - name: Create dev-build release + if: ${{ github.event_name == 'push' }} + uses: softprops/action-gh-release@v1 + with: + generate_release_notes: true + files: bin/*/uad_gui-* + prerelease: true + tag_name: ${{ env.dev_tag }}