diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..2527b4b --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,131 @@ +on: + push: + tags: + - "v[0-9]+.[0-9]+.[0-9]+" + +jobs: + create-release: + name: create-release + runs-on: ubuntu-latest + steps: + - name: Create artifacts directory + run: mkdir artifacts + + - name: Get the release version from the tag + if: env.VERSION == '' + run: | + echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV + echo "version is: ${{ env.VERSION }}" + + - name: Create GitHub release + id: release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ env.VERSION }} + release_name: ${{ env.VERSION }} + + - name: Save release upload URL to artifact + run: echo "${{ steps.release.outputs.upload_url }}" > artifacts/release-upload-url + + - name: Save version number to artifact + run: echo "${{ env.VERSION }}" > artifacts/release-version + + - name: Upload artifacts + uses: actions/upload-artifact@v1 + with: + name: artifacts + path: artifacts + + build-release: + name: build-release + needs: ["create-release"] + runs-on: ${{ matrix.os }} + env: + # When CARGO is set to CROSS, TARGET_DIR includes matrix.target. + TARGET_DIR: ./target + # Emit backtraces on panics. + RUST_BACKTRACE: 1 + MACOSX_DEPLOYMENT_TARGET: 10.9 + + strategy: + matrix: + build: [linux, linux-static] + include: + - build: linux + os: ubuntu-latest + rust: stable + target: x86_64-unknown-linux-gnu + - build: linux-static + os: ubuntu-latest + rust: stable + target: x86_64-unknown-linux-musl + + steps: + - uses: actions/checkout@v3 + name: Checkout repository + with: + fetch-depth: 0 + + - name: Checkout submodule + run: git submodule update --init --recursive + + - name: Install Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ matrix.rust }} + profile: minimal + override: true + target: ${{ matrix.target }} + + - name: Get release download URL + uses: actions/download-artifact@v1 + with: + name: artifacts + path: artifacts + + - name: Set release upload URL and release version + shell: bash + run: | + release_upload_url="$(cat artifacts/release-upload-url)" + echo "RELEASE_UPLOAD_URL=$release_upload_url" >> $GITHUB_ENV + echo "release upload url: $RELEASE_UPLOAD_URL" + release_version="$(cat artifacts/release-version)" + echo "RELEASE_VERSION=$release_version" >> $GITHUB_ENV + echo "release version: $RELEASE_VERSION" + + - name: Build release binary + if: matrix.build == 'linux' || matrix.build == 'macos' || matrix.build == 'windows' + uses: actions-rs/cargo@v1 + with: + command: build + toolchain: "${{ matrix.rust }}" + args: --target ${{ matrix.target }} --release + + - name: Build release binary + if: matrix.build == 'linux-static' + uses: actions-rs/cargo@v1 + with: + command: build + args: --target ${{ matrix.target }} --release + + - name: Build archive + shell: bash + run: | + if [ "${{ matrix.build }}" = "windows" ]; then + echo "ASSET=target/${{ matrix.target }}/release/ntfs-undelete.exe" >> $GITHUB_ENV + echo "ASSET_NAME=ntfs-undelete-${{ env.RELEASE_VERSION }}.exe" >> $GITHUB_ENV + else + echo "ASSET=target/${{ matrix.target }}/release/ntfs-undelete" >> $GITHUB_ENV + echo "ASSET_NAME=ntfs-undelete-${{ env.RELEASE_VERSION }}-${{ matrix.target }}" >> $GITHUB_ENV + fi + - name: Upload release archive + uses: actions/upload-release-asset@v1.0.1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ env.RELEASE_UPLOAD_URL }} + asset_path: ${{ env.ASSET }} + asset_name: ${{ env.ASSET_NAME }} + asset_content_type: application/octet-stream \ No newline at end of file diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c480f45..fa35589 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -18,6 +18,9 @@ jobs: name: Checkout repository with: fetch-depth: 0 + + - name: Checkout submodule + run: git submodule update --init --recursive - uses: actions/cache@v3 name: Setup cache registry @@ -41,17 +44,9 @@ jobs: name: Setup rust toolchain with: profile: minimal - toolchain: nightly + toolchain: stable override: true - - name: Setup external deps - run: | - sudo apt-get update - sudo apt-get install libtsk-dev - rustup component add clippy --toolchain nightly-x86_64-unknown-linux-gnu - sudo ln -s /usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/libtsk.a /usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/liblibtsk.a - sudo ln -s /usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/libtsk.so /usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/liblibtsk.so - - uses: actions-rs/cargo@v1 name: Run cargo check with: diff --git a/README.md b/README.md index 4c3232e..11d4c7e 100644 --- a/README.md +++ b/README.md @@ -32,13 +32,19 @@ The Rust NTFS Undelete Tool is a command-line utility for recovering deleted fil cd ntfs-undelete ``` -2. Build the project with cargo: +2. Update submodules: + + ```bash + git submodule update --init --recursive + ``` + +3. Build the project with cargo: ```bash cargo build --release ``` -3. The binary will be available in the `target/release/` directory. You can either add this directory to your `PATH` environment variable or copy the binary to your desired location. +4. The binary will be available in the `target/release/` directory. You can either add this directory to your `PATH` environment variable or copy the binary to your desired location. ### Download a prebuilt binary *TODO!*