Add release action

This commit is contained in:
Kasper 2022-12-30 12:42:24 +01:00
parent de79887331
commit 81f5f9d401
No known key found for this signature in database
GPG Key ID: 356D5C59EDCEC2D1
3 changed files with 65 additions and 35 deletions

56
.github/workflows/release.yml vendored Normal file
View File

@ -0,0 +1,56 @@
name: Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
jobs:
create-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Create Release
uses: softprops/action-gh-release@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: ''
draft: true
upload:
needs: create-release
strategy:
matrix:
include:
- os: macos-latest
target: x86_64-apple-darwin
archive: $bin-$tag-macos-x64
- os: macos-latest
target: aarch64-apple-darwin
archive: $bin-$tag-macos-aarch64
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
archive: $bin-$tag-linux-x64
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
archive: $bin-$tag-linux-aarch64
- os: windows-latest
target: x86_64-pc-windows-gnu
archive: $bin-$tag-windows-x64
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Build & upload
uses: taiki-e/upload-rust-binary-action@v1
with:
bin: csv-pipeline
target: ${{ matrix.target }}
archive: ${{ matrix.archive }}
zip: all
tar: none
token: ${{ secrets.GITHUB_TOKEN }}

View File

@ -1,3 +1,9 @@
# Changelog
## Next
- Add `marathon` unit
- Add `macos-aarch64` (Apple Silicon) and `linux-aarch64` release binaries
## 1.8.0 - 2021 Aug 16
- Add support for data transfer rate units (like mb/s)
- Add support for dividing length by speed (like 10 km / 100 kph)

View File

@ -1,5 +1,3 @@
[documentation]: https://docs.rs/cpc
# cpc
calculation + conversion
@ -183,41 +181,11 @@ match string {
- Angles
- Flow rate
### Cross-compiling (from x86_64 macOS)
1. [Install Docker](https://docs.docker.com/get-docker/)
2. Install [`cross`](https://github.com/rust-embedded/cross). `cross` works by installing toolchains for whatever target you're building for, then using those toolchains to compile in Docker containers
```
cargo install cross
```
3. Set rustup profile to minimal. This means things like `rustdoc` won't be included in new toolchain installations. You can run `rustup set profile default` to reset this afterwards.
```
rustup set profile minimal
```
4. Build for x86_64 macOS, Linux and Windows. For more targets, check out [the targets `cross` supports](https://github.com/rust-embedded/cross#supported-targets)
```
cargo build --release --target x86_64-apple-darwin &&
cross build --release --target x86_64-unknown-linux-musl &&
cross build --release --target x86_64-pc-windows-gnu
```
5. The compiled binaries will now be available inside `target/<target>/release/`. The filename will be either `cpc` or `cpc.exe`.
### Releasing a new version
1. Update `CHANGELOG.md`
2. Bump the version number in `Cargo.toml`
3. Run `cargo test`
4. Cross-compile cpc by following [the steps above](#cross-compiling)
5. Commit and tag in format `v#.#.#`
6. Publish on crates.io:
1. Login by running `cargo login` and following the instructions
2. Test publish to ensure there are no issues
```
cargo publish --dry-run
```
3. Publish
```
cargo publish
```
7. Publish on GitHub
1. Zip the binaries and rename them like `cpc-v#.#.#-macos-x64`
2. Create GitHub release with release notes and attach the zipped binaries
4. Create a git tag in format `v#.#.#`
5. Add release notes to the generated GitHub release and publish it
6. Run `cargo publish`