Skip to content

Commit f73a1a1

Browse files
authored
Automatic binary release on GitHub (#64)
* Automatic binary release on GitHub * Fix clippy warning
1 parent 4a9e304 commit f73a1a1

File tree

5 files changed

+199
-39
lines changed

5 files changed

+199
-39
lines changed

.github/workflows/main.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: main
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
schedule:
7+
- cron: 0 0 1 * *
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
12+
jobs:
13+
cargo-test:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout source
17+
uses: actions/checkout@v2
18+
19+
- name: Get main commit hash
20+
id: main_commit
21+
run: echo "::set-output name=hash::$(git rev-parse origin/main)"
22+
23+
- name: Cache target, rustup and cargo registry
24+
id: cache-target
25+
uses: actions/cache@v2
26+
with:
27+
path: |
28+
~/.rustup
29+
~/.cargo/registry
30+
~/.cargo/bin
31+
target
32+
key: main-${{ steps.main_commit.outputs.hash }}
33+
34+
- name: cargo test
35+
uses: actions-rs/cargo@v1
36+
with:
37+
command: test
38+
args: --workspace

.github/workflows/pr.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: PR
2+
3+
on:
4+
pull_request:
5+
branches: [ main ]
6+
7+
env:
8+
CARGO_TERM_COLOR: always
9+
10+
jobs:
11+
cargo-test-and-lint:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout source
15+
uses: actions/checkout@v2
16+
17+
- name: Get main commit hash
18+
id: main_commit
19+
run: echo "::set-output name=hash::$(git rev-parse origin/main)"
20+
21+
- name: Cache target, rustup and cargo registry
22+
id: cache-target
23+
uses: actions/cache@v2
24+
with:
25+
path: |
26+
~/.rustup
27+
~/.cargo/registry
28+
~/.cargo/bin
29+
target
30+
key: ${{ github.event.issue.number }}-${{ runner.os }}-pr
31+
restore-keys: main-${{ steps.main_commit.outputs.hash }}
32+
33+
- name: cargo test
34+
uses: actions-rs/cargo@v1
35+
with:
36+
command: test
37+
args: --workspace
38+
39+
- name: rustfmt
40+
uses: actions-rs/cargo@v1
41+
with:
42+
command: fmt
43+
args: --all -- --check
44+
45+
- name: clippy
46+
uses: actions-rs/clippy-check@v1
47+
with:
48+
token: ${{ secrets.GITHUB_TOKEN }}
49+
args: -- -D warnings

.github/workflows/release.yml

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
name: Release Workflow
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
build-linux:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout source
13+
uses: actions/checkout@v2
14+
- name: Build release (Linux)
15+
uses: actions-rs/cargo@v1
16+
with:
17+
command: build
18+
args: --release
19+
- run: strip target/release/gptman
20+
- uses: actions/upload-artifact@v2
21+
with:
22+
name: binary-linux
23+
path: target/release/gptman
24+
25+
build-windows:
26+
runs-on: windows-latest
27+
steps:
28+
- name: Checkout source
29+
uses: actions/checkout@v2
30+
- name: Build release (Windows)
31+
uses: actions-rs/cargo@v1
32+
with:
33+
command: build
34+
args: --release --target=x86_64-pc-windows-msvc
35+
- uses: actions/upload-artifact@v2
36+
with:
37+
name: binary-windows
38+
path: target/x86_64-pc-windows-msvc/release/gptman.exe
39+
40+
build-osx-x86:
41+
runs-on: macos-latest
42+
steps:
43+
- name: Checkout source
44+
uses: actions/checkout@v2
45+
- name: Build release (OSX)
46+
uses: actions-rs/cargo@v1
47+
with:
48+
command: build
49+
args: --release
50+
- uses: actions/upload-artifact@v2
51+
with:
52+
name: binary-osx
53+
path: target/release/gptman
54+
55+
release:
56+
needs: [build-linux, build-windows, build-osx-x86]
57+
runs-on: ubuntu-latest
58+
steps:
59+
- name: Get the version
60+
id: get_version
61+
run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/}
62+
- uses: actions/download-artifact@v2
63+
with:
64+
name: binary-linux
65+
path: binary-linux
66+
- uses: actions/download-artifact@v2
67+
with:
68+
name: binary-windows
69+
path: binary-windows
70+
- uses: actions/download-artifact@v2
71+
with:
72+
name: binary-osx
73+
path: binary-osx
74+
- name: Create Release
75+
id: create_release
76+
uses: actions/create-release@v1
77+
env:
78+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
79+
with:
80+
tag_name: ${{ github.ref }}
81+
release_name: Release ${{ github.ref }}
82+
body: gptman release ${{ steps.get_version.outputs.VERSION }}
83+
draft: false
84+
prerelease: false
85+
- name: Upload Release Asset Linux
86+
uses: actions/upload-release-asset@v1
87+
env:
88+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
89+
with:
90+
upload_url: ${{ steps.create_release.outputs.upload_url }}
91+
asset_path: binary-linux/gptman
92+
asset_name: gptman-${{ steps.get_version.outputs.VERSION }}-linux-x86_64
93+
asset_content_type: application/x-pie-executable
94+
- name: Upload Release Asset Windows
95+
uses: actions/upload-release-asset@v1
96+
env:
97+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
98+
with:
99+
upload_url: ${{ steps.create_release.outputs.upload_url }}
100+
asset_path: binary-windows/gptman.exe
101+
asset_name: gptman-${{ steps.get_version.outputs.VERSION }}-win-x86_64.exe
102+
asset_content_type: application/x-dosexec
103+
- name: Upload Release Asset OSX
104+
uses: actions/upload-release-asset@v1
105+
env:
106+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
107+
with:
108+
upload_url: ${{ steps.create_release.outputs.upload_url }}
109+
asset_path: binary-osx/gptman
110+
asset_name: gptman-${{ steps.get_version.outputs.VERSION }}-osx-x86_64
111+
asset_content_type: application/x-mach-binary

.github/workflows/rust.yml

Lines changed: 0 additions & 38 deletions
This file was deleted.

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -926,7 +926,7 @@ impl GPT {
926926
positions.push(partition.ending_lba);
927927
}
928928
positions.push(self.header.last_usable_lba + 1);
929-
positions.sort();
929+
positions.sort_unstable();
930930

931931
positions
932932
.chunks(2)

0 commit comments

Comments
 (0)