Skip to content

Commit

Permalink
ci fix (#23)
Browse files Browse the repository at this point in the history
* ci fix

* fix readme

* adding release process

* removing builds

* fixing ubuntu versinos

* fixing checkouts

* fixing names of binaries
  • Loading branch information
NikolaMilosa authored Nov 18, 2023
1 parent b82d013 commit 2f7ebd3
Show file tree
Hide file tree
Showing 3 changed files with 143 additions and 11 deletions.
131 changes: 131 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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
13 changes: 4 additions & 9 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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!*
Expand Down

0 comments on commit 2f7ebd3

Please sign in to comment.