Skip to content

Commit

Permalink
ci: add auto publish (#17)
Browse files Browse the repository at this point in the history
* test: add crate publish dummy job

* fix: move publish step to tail

* test: try artifact

* chore: change text

* fix: support `test-release**` tag

* refactor: use market's action

* refactor: use latest checkout action

* fix: dry run if test-release

* refactor: use latest updater

* fix: add meta version

* perf(ci): use debug compile in non-release CI

* fix: reverse condition

* chore: change build metadata in version

* fix: always generate sha256
  • Loading branch information
JyJyJcr authored Mar 17, 2024
1 parent 4887a92 commit 5d37061
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 28 deletions.
9 changes: 3 additions & 6 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
name: Code Lint
on: [push]

name: build

jobs:
check:
name: Rust project
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Install latest nightly
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: rustfmt, clippy

- name: Cargo format
run: cargo fmt --all -- --check

- name: Cargo clippy
run: cargo clippy --all-targets
run: cargo clippy --all-targets
55 changes: 35 additions & 20 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Tests and release
name: Test & Release

on:
push:
Expand All @@ -14,12 +14,13 @@ env:
RUST_BACKTRACE: 1

jobs:
test:
build:
permissions: write-all
name: ${{ matrix.platform.os_name }} with rust ${{ matrix.toolchain }}
name: Compile ${{ matrix.platform.os_name }} with Rust ${{ matrix.toolchain }}
runs-on: ${{ matrix.platform.os }}
strategy:
fail-fast: false
# assert perfect success
fail-fast: true
matrix:
platform:
# Platforms that don't work:
Expand Down Expand Up @@ -70,7 +71,7 @@ jobs:
toolchain:
- stable
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Cache cargo & target directories
uses: Swatinem/rust-cache@v2
- name: Install musl-tools on Linux
Expand All @@ -82,9 +83,10 @@ jobs:
command: "build"
target: ${{ matrix.platform.target }}
toolchain: ${{ matrix.toolchain }}
args: "--locked --release"
args: ${{ (startsWith(github.ref, 'refs/tags/test-release') || startsWith(github.ref,'refs/tags/v')) && '--locked --release' || '--locked' }} # short evaluation emulates ternary conditional operator
strip: true
- name: Package as archive
# in future we would need bundle etc files
shell: bash
run: |
cd target/${{ matrix.platform.target }}/release
Expand All @@ -94,26 +96,39 @@ jobs:
tar czvf ../../../${{ matrix.platform.name }} ${{ matrix.platform.bin }}
fi
cd -
if: |
matrix.toolchain == 'stable' &&
( startsWith( github.ref, 'refs/tags/v' ) ||
github.ref == 'refs/tags/test-release' )
if: (startsWith(github.ref, 'refs/tags/test-release') || startsWith(github.ref,'refs/tags/v'))
- name: Generate SHA-256
run: shasum -a 256 ${{ matrix.platform.name }}
if: (startsWith(github.ref, 'refs/tags/test-release') || startsWith(github.ref,'refs/tags/v'))
- name: Publish release artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: quicssh-${{ matrix.platform.os_name }}
path: "quicssh-*"
if: matrix.toolchain == 'stable' && github.ref == 'refs/tags/test-release'
- name: Generate SHA-256
run: shasum -a 256 ${{ matrix.platform.name }}
if: |
matrix.toolchain == 'stable' &&
matrix.platform.os == 'macOS-latest' &&
( startsWith( github.ref, 'refs/tags/v' ) ||
github.ref == 'refs/tags/test-release' )
if: startsWith(github.ref, 'refs/tags/test-release')
- name: Publish GitHub release
uses: softprops/action-gh-release@v1
with:
draft: true
files: "quicssh-*"
if: matrix.toolchain == 'stable' && startsWith( github.ref, 'refs/tags/v' )
if: matrix.toolchain == 'stable' && startsWith(github.ref,'refs/tags/v')
crate:
permissions: write-all
name: publish crate.io release
runs-on: ubuntu-latest
needs: build
if: (startsWith(github.ref, 'refs/tags/test-release') || startsWith(github.ref,'refs/tags/v'))
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Cache cargo & target directories
uses: Swatinem/rust-cache@v2
- name: publish crate.io release (dummy)
uses: katyo/publish-crates@v2
with:
registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}
dry-run: ${{ startsWith(github.ref, 'refs/tags/test-release') }}

2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "quicssh-rs"
version = "0.1.3"
version = "0.1.3+autopublish"
edition = "2021"
license = "MIT"
authors = ["oowl <[email protected]>"]
Expand Down

0 comments on commit 5d37061

Please sign in to comment.