-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 7eb8e7a
Showing
147 changed files
with
31,355 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,169 @@ | ||
name: Build then release | ||
|
||
on: | ||
push: | ||
tags: | ||
- "v*" | ||
branches: | ||
- "main" | ||
|
||
env: | ||
CARGO_TERM_COLOR: always | ||
|
||
jobs: | ||
gen_version: | ||
name: Generate version | ||
runs-on: ubuntu-latest | ||
outputs: | ||
version: ${{ steps.generated-tag.outputs.tag }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Get latest tag | ||
id: get-latest-tag | ||
run: | | ||
echo "tag=`gh release list -L 1 | cut -f 1`" >> $GITHUB_OUTPUT | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Bump version | ||
id: generated-tag | ||
uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
if (context.ref.startsWith("refs/tags/")) { | ||
let tag = context.ref.replace("refs/tags/", ""); | ||
core.setOutput('tag', tag); | ||
console.log(`This event pushed a tag ${tag}, return directly.`) | ||
return | ||
} | ||
console.log('Use default tag "prerelease".') | ||
core.setOutput('tag', 'prerelease'); | ||
build: | ||
needs: gen_version | ||
name: Build | ||
runs-on: ${{ matrix.runner }} | ||
strategy: | ||
matrix: | ||
include: | ||
- target: x86_64-apple-darwin | ||
runner: macos-latest | ||
build_env: {} | ||
- target: aarch64-apple-darwin | ||
runner: macos-latest | ||
build_env: {} | ||
- target: x86_64-unknown-linux-musl | ||
runner: ubuntu-latest | ||
build_env: {} | ||
- target: aarch64-unknown-linux-musl | ||
runner: ubuntu-latest | ||
build_env: | ||
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_RUSTFLAGS: "-Clink-self-contained=yes -Clinker=rust-lld" | ||
CC_aarch64_unknown_linux_musl: clang | ||
AR_aarch64_unknown_linux_musl: llvm-ar | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Setup protoc | ||
uses: arduino/[email protected] | ||
with: | ||
repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Install musl-tools | ||
if: matrix.runner == 'ubuntu-latest' | ||
run: sudo apt update && sudo apt install -y musl-tools | ||
- name: Install cross build deps for aarch64-unknown-linux-musl | ||
if: matrix.target == 'aarch64-unknown-linux-musl' | ||
run: sudo apt update && sudo apt install -y clang llvm gcc-aarch64-linux-gnu | ||
- name: Add target | ||
run: rustup target add ${{ matrix.target }} | ||
- name: Setup rust toolchain | ||
run: rustup show | ||
- uses: Swatinem/rust-cache@v2 | ||
with: | ||
shared-key: build-then-release-${{ matrix.target }}-v1 | ||
- name: Build | ||
env: ${{ matrix.build_env }} | ||
run: | | ||
cargo build --release --target ${{ matrix.target }} | ||
- name: Compress | ||
run: | | ||
zip -j dephy-decharge-controller-node-${{ needs.gen_version.outputs.version }}-${{ matrix.target }}.zip ./target/${{ matrix.target }}/release/dephy-decharge-controller-node && | ||
zip -j dephy-decharge-controller-server-${{ needs.gen_version.outputs.version }}-${{ matrix.target }}.zip ./target/${{ matrix.target }}/release/dephy-decharge-controller-server && | ||
zip -j dephy-gacha-controller-${{ needs.gen_version.outputs.version }}-${{ matrix.target }}.zip ./target/${{ matrix.target }}/release/dephy-gacha-controller | ||
- uses: actions/upload-artifact@v4 | ||
name: Upload artifacts | ||
with: | ||
name: dephy-balance-payment-example-${{ needs.gen_version.outputs.version }}-${{ matrix.target }} | ||
path: "*.zip" | ||
retention-days: 1 | ||
|
||
release: | ||
needs: [gen_version, build] | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Generate changelog | ||
uses: orhun/git-cliff-action@v3 | ||
id: git-cliff | ||
with: | ||
config: cliff.toml | ||
args: "-vv --strip header ${{ needs.gen_version.outputs.version == 'prerelease' && '--unreleased' || '--latest' }}" | ||
- uses: actions/download-artifact@v4 | ||
- name: Display fetched artifacts | ||
run: ls -R | ||
- uses: softprops/[email protected] | ||
name: Emit a Github Release | ||
with: | ||
token: "${{ secrets.GITHUB_TOKEN }}" | ||
body: "${{ steps.git-cliff.outputs.content }}" | ||
tag_name: ${{ needs.gen_version.outputs.version }} | ||
prerelease: ${{ needs.gen_version.outputs.version == 'prerelease' }} | ||
files: | | ||
LICENSE | ||
dephy-balance-payment-example-${{ needs.gen_version.outputs.version }}-x86_64-apple-darwin/*.zip | ||
dephy-balance-payment-example-${{ needs.gen_version.outputs.version }}-aarch64-apple-darwin/*.zip | ||
dephy-balance-payment-example-${{ needs.gen_version.outputs.version }}-x86_64-unknown-linux-musl/*.zip | ||
dephy-balance-payment-example-${{ needs.gen_version.outputs.version }}-aarch64-unknown-linux-musl/*.zip | ||
image: | ||
needs: [gen_version, build] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: docker/setup-buildx-action@v3 | ||
- uses: actions/download-artifact@v4 | ||
- name: Log in to the Container registry | ||
uses: docker/[email protected] | ||
with: | ||
username: ${{ vars.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
- name: Extract metadata for Docker | ||
id: meta | ||
uses: docker/[email protected] | ||
with: | ||
images: ${{ vars.DOCKERHUB_USERNAME }}/dephy-balance-payment-example | ||
- name: Extract all released executable files | ||
run: | | ||
for dir in dephy-balance-payment-example-${{ needs.gen_version.outputs.version }}-*/; do | ||
for zip_file in "$dir"*.zip; do | ||
[ -f "$zip_file" ] && unzip "$zip_file" -d "$dir" && rm "$zip_file" | ||
done | ||
done | ||
- name: Display fetched artifacts | ||
run: ls -R | ||
- name: Move directory for platforms | ||
run: | | ||
mkdir linux && | ||
mv dephy-balance-payment-example-${{ needs.gen_version.outputs.version }}-x86_64-unknown-linux-musl linux/amd64 && | ||
mv dephy-balance-payment-example-${{ needs.gen_version.outputs.version }}-aarch64-unknown-linux-musl linux/arm64 | ||
- name: Display moved files | ||
run: ls -R | ||
- name: Build and push Docker image | ||
id: push | ||
uses: docker/[email protected] | ||
with: | ||
context: . | ||
platforms: linux/amd64,linux/arm64 | ||
tags: ${{ steps.meta.outputs.tags }} | ||
push: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: Check and test | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
env: | ||
CARGO_TERM_COLOR: always | ||
|
||
jobs: | ||
test: | ||
name: Check and test | ||
strategy: | ||
matrix: | ||
platform: [ubuntu-latest] | ||
runs-on: ${{ matrix.platform }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Setup rust toolchain | ||
run: | | ||
rustup install nightly | ||
rustup component add rustfmt --toolchain nightly | ||
rustup show | ||
- name: Install nextest | ||
uses: taiki-e/install-action@nextest | ||
- uses: Swatinem/rust-cache@v2 | ||
with: | ||
shared-key: check-and-test-${{ matrix.platform }}-v1 | ||
- name: Check code format | ||
run: cargo +nightly fmt -- --check | ||
- name: Check the package for errors | ||
run: cargo check --all | ||
- name: Lint rust sources | ||
run: cargo clippy --all-targets --all-features --tests --benches -- -D warnings | ||
- name: Execute rust tests | ||
run: cargo nextest run --all-features --no-tests=pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
.env | ||
.DS_Store | ||
target | ||
.anchor | ||
*.rs.bk | ||
node_modules | ||
test-ledger | ||
.yarn | ||
bun.lock | ||
bun.lockb | ||
package-lock.json | ||
data | ||
tmp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
fail_fast: false | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.6.0 | ||
hooks: | ||
- id: check-case-conflict | ||
- id: check-merge-conflict | ||
- id: check-symlinks | ||
- id: check-yaml | ||
- id: end-of-file-fixer | ||
- id: fix-byte-order-marker | ||
- id: mixed-line-ending | ||
- id: trailing-whitespace | ||
- repo: local | ||
hooks: | ||
- id: taplo | ||
name: taplo format | ||
description: Format Cargo.toml files with taplo. | ||
entry: bash -c 'taplo format --check' | ||
language: rust | ||
files: Cargo.toml$ | ||
- id: cargo-fmt | ||
name: cargo fmt | ||
description: Format files with rustfmt. | ||
entry: bash -c 'cargo +nightly fmt -- --check' | ||
language: rust | ||
files: \.rs$ | ||
- id: cargo-deny | ||
name: cargo deny check | ||
description: Check cargo dependencies | ||
entry: bash -c 'cargo deny check -d' | ||
language: rust | ||
files: \.*$ | ||
- id: typos | ||
name: typos | ||
description: check typo | ||
entry: bash -c 'typos' | ||
language: rust | ||
files: \.*$ | ||
pass_filenames: false | ||
- id: cargo-check | ||
name: cargo check | ||
description: Check the package for errors. | ||
entry: bash -c 'cargo check --all' | ||
language: rust | ||
files: \.rs$ | ||
pass_filenames: false | ||
- id: cargo-clippy | ||
name: cargo clippy | ||
description: Lint rust sources | ||
entry: bash -c 'cargo clippy --all-targets --all-features --tests --benches -- -D warnings' | ||
language: rust | ||
files: \.rs$ | ||
pass_filenames: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.anchor | ||
.DS_Store | ||
target | ||
node_modules | ||
dist | ||
build | ||
test-ledger | ||
|
||
bun.lockb |
Oops, something went wrong.