diff --git a/.github/workflows/CD.yml b/.github/workflows/CD.yml index 3f14f9f..2404ab8 100644 --- a/.github/workflows/CD.yml +++ b/.github/workflows/CD.yml @@ -1,48 +1,118 @@ -name: Publish +name: Publish latest on: push: + branches: + - main tags: - '*' +env: + CARGO_TERM_COLOR: always + jobs: - binary: - name: Publish binary for ${{ matrix.os }} + upload_license: + name: Upload License + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/upload-artifact@v3 + with: + name: LICENSE + path: LICENSE + + build: + name: Build onagre ${{ matrix.os }}-${{ matrix.target }} runs-on: ${{ matrix.os }} strategy: matrix: - # This should work with only the `include`s but it currently doesn't because of this bug: - # https://github.community/t5/How-to-use-Git-and-GitHub/GitHub-Actions-Matrix-options-dont-work-as-documented/td-p/29558 - target: [ x86_64-unknown-linux-gnu, x86_64-unknown-linux-musl, armv7-unknown-linux-musleabihf ] include: - - os: ubuntu-22.04 + - os: ubuntu-latest target: x86_64-unknown-linux-gnu - - os: ubuntu-22.04 + - os: ubuntu-latest target: x86_64-unknown-linux-musl - - os: ubuntu-22.04 + - os: ubuntu-latest target: armv7-unknown-linux-musleabihf - steps: - - uses: hecrj/setup-rust-action@v1 + - uses: actions/checkout@v4 + + - uses: Swatinem/rust-cache@v2 with: - rust-version: stable + cache-all-crates: "true" + key: "${{ matrix.os }}-${{ matrix.target }}" - - name: Install libssl-dev - if: ${{ matrix.os == 'ubuntu-22.04' }} - run: sudo apt-get update && sudo apt-get install cmake mingw-w64 + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + target: ${{ matrix.target }} + + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install libxkbcommon-dev libvulkan1 mesa-vulkan-drivers libegl1-mesa-dev + + - uses: actions-rs/cargo@v1 + with: + use-cross: true + command: build + args: --target ${{ matrix.target }} --release --locked - - uses: actions/checkout@v1 - - name: Build - run: ci/action.sh release ${{ matrix.target }} + - uses: actions/upload-artifact@v3 + with: + name: ${{ matrix.target }} + path: target/${{ matrix.target }}/release/onagre - - name: Get the version - id: get_version - run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} - - name: Upload binaries to release - uses: svenstaro/upload-release-action@v1-release + upload_to_release: + needs: [ build, upload_license] + name: Publish onagre binaries + runs-on: ubuntu-latest + if: ${{ github.ref_type == 'tag' }} + steps: + - uses: actions/download-artifact@v3 + with: + path: ~/artifacts + + - name: Copy artifacts to archive + run: | + mkdir x86_64-unknown-linux-musl + cp -r /home/runner/artifacts/x86_64-unknown-linux-musl/onagre x86_64-unknown-linux-musl/onagre + chmod +x -R x86_64-unknown-linux-musl/onagre + cp -r /home/runner/artifacts/LICENSE/LICENSE x86_64-unknown-linux-musl/ + tar -czf onagre-x86_64-unknown-linux-musl.tar.gz x86_64-unknown-linux-musl/* + + mkdir x86_64-unknown-linux-gnu + cp -r /home/runner/artifacts/x86_64-unknown-linux-gnu/onagre x86_64-unknown-linux-gnu/onagre + chmod +x -R x86_64-unknown-linux-gnu/onagre + cp -r /home/runner/artifacts/LICENSE/LICENSE x86_64-unknown-linux-gnu/ + tar -czf onagre-x86_64-unknown-linux-gnu.tar.gz x86_64-unknown-linux-gnu/* + + mkdir armv7-unknown-linux-musleabihf + cp -r /home/runner/artifacts/armv7-unknown-linux-musleabihf/onagre armv7-unknown-linux-musleabihf/onagre + chmod +x -R armv7-unknown-linux-musleabihf/onagre + cp -r /home/runner/artifacts/LICENSE/LICENSE armv7-unknown-linux-musleabihf/ + tar -czf onagre-armv7-unknown-linux-musleabihf.tar.gz armv7-unknown-linux-musleabihf/* + + - uses: svenstaro/upload-release-action@v1-release with: repo_token: ${{ secrets.GITHUB_TOKEN }} - file: target/tar/onagre.tar.gz + file: onagre-x86_64-unknown-linux-musl.tar.gz tag: ${{ github.ref }} - asset_name: onagre-${{ steps.get_version.outputs.VERSION }}-${{ matrix.target }}.tar.gz + asset_name: onagre-${{ github.ref_name }}-x86_64-unknown-linux-musl.tar.gz + + - uses: svenstaro/upload-release-action@v1-release + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: onagre-armv7-unknown-linux-musleabihf.tar.gz + tag: ${{ github.ref_name }} + asset_name: onagre-${{ github.ref_name }}-armv7-unknown-linux-musleabihf.tar.gz + + - uses: svenstaro/upload-release-action@v1-release + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: onagre-armv7-unknown-linux-musleabihf.tar.gz + tag: ${{ github.ref_name }} + asset_name: onagre-${{ github.ref_name }}-armv7-unknown-linux-musleabihf.tar.gz + + diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 3e3510b..3b099e7 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -30,7 +30,7 @@ jobs: git config --global user.name github-actions - name: Conventional commit check - uses: cocogitto/cocogitto-action@v3.5 + uses: cocogitto/cocogitto-action@v3 with: git-user: 'github-actions' git-user-email: 'github-actions@github.com' diff --git a/.github/workflows/Release.yaml b/.github/workflows/Release.yaml new file mode 100644 index 0000000..66841f0 --- /dev/null +++ b/.github/workflows/Release.yaml @@ -0,0 +1,58 @@ +name: Release + +on: + workflow_dispatch: + +jobs: + release: + name: SemVer release + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{secrets.RELEASE_TOKEN}} + + - run: | + git config user.name github-actions + git config user.email github-actions@github.com + git config --global user.email github-actions@github.com + git config --global user.name github-actions + + - name: Install stable toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + + - run: + cargo install cargo-edit + + - run: + cargo login ${{secrets.CARGO_TOKEN}} + + - name: SemVer release + id: release + uses: cocogitto/cocogitto-action@v3 + with: + check-latest-tag-only: true + release: true + git-user: 'github-actions' + git-user-email: 'github-actions@github.com' + + - name: Generate Changelog + run: cog changelog --at ${{ steps.release.outputs.version }} -t full_hash > GITHUB_CHANGELOG.md + + - name: Upload github release + uses: softprops/action-gh-release@v1 + with: + body_path: GITHUB_CHANGELOG.md + tag_name: ${{ steps.release.outputs.version }} + +# - name: vuepress-deploy +# uses: jenkey2011/vuepress-deploy@master +# env: +# COMMIT_MESSAGE: "chore: update gh-pages" +# ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }} +# BUILD_SCRIPT: cd docs && yarn && yarn docs:build +# BUILD_DIR: website/.vuepress/dist/ \ No newline at end of file diff --git a/ci/action.sh b/ci/action.sh deleted file mode 100755 index cfe8096..0000000 --- a/ci/action.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail - -export ONAGRE_HOME="$(cd "$(dirname "$0")/.." && pwd)" - -echoerr() { - echo "$@" 1>&2 -} - -release() { - - TAR_DIR="${ONAGRE_HOME}/target/tar" - - target="${1:-}" - if [[ $target == *"osx"* ]]; then - echoerr "OSX cross-compile is impossible. Fallbacking to cargo..." - target="" - fi - - cd "$ONAGRE_HOME" - - rm -rf "${ONAGRE_HOME}/target" 2> /dev/null || true - - if [ -n "$target" ]; then - cargo install --version 0.1.16 cross 2> /dev/null || true - cross build --release --target "$target" - bin_folder="${target}/release" - else - cargo build --release - bin_folder="release" - fi - - bin_path="${ONAGRE_HOME}/target/${bin_folder}/onagre" - chmod +x "$bin_path" - mkdir -p "$TAR_DIR" 2> /dev/null || true - - cp "$bin_path" "$TAR_DIR" - cp "$ONAGRE_HOME/LICENSE" "$TAR_DIR" - - cd "$TAR_DIR" - tar -czf onagre.tar.gz * - -} - -cmd="$1" -shift - -release "$@" \ No newline at end of file diff --git a/rustfmt.toml b/rustfmt.toml deleted file mode 100644 index d9c6de2..0000000 --- a/rustfmt.toml +++ /dev/null @@ -1 +0,0 @@ -imports_granularity = "Module" \ No newline at end of file