Skip to content

publish: key_parse: 0.3.0, lcode: 0.10.0, leetcode-api: 0.6.0 lcode-c… #59

publish: key_parse: 0.3.0, lcode: 0.10.0, leetcode-api: 0.6.0 lcode-c…

publish: key_parse: 0.3.0, lcode: 0.10.0, leetcode-api: 0.6.0 lcode-c… #59

Workflow file for this run

name: Release
permissions:
contents: write
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
env:
BIN_NAME: lcode
PROJECT_NAME: lcode
jobs:
publish:
runs-on: ubuntu-latest
environment: cargo
env:
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"
steps:
- name: Fetch Repository
uses: actions/checkout@v4
- name: Install Stable Rust Toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
- name: Rust version
id: rustc-version
run: |
echo "rustc=$(rustc --version)" >> "$GITHUB_OUTPUT"
- name: Run sccache-cache
uses: mozilla-actions/[email protected]
- name: Install cargo-binstall
uses: taiki-e/install-action@v2
with:
tool: cargo-binstall
- name: Install cargo-release
run: cargo binstall -y --force --locked cargo-release
- name: Install Dbus
run: sudo apt update && sudo apt install libdbus-1-dev pkg-config
- name: Publish crate
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: |
cargo release publish \
--allow-branch HEAD \
--no-confirm \
--workspace -x \
|| echo "Some crates not publish."
create-release:
# needs: [publish]
runs-on: ubuntu-latest
steps:
- name: Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
draft: false
prerelease: false
generate_release_notes: true
check-if-bin:
runs-on: ubuntu-latest
steps:
- name: Fetch Repository
uses: actions/checkout@v4
- name: Run sccache-cache
uses: mozilla-actions/[email protected]
env:
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"
- name: Install Stable Rust Toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
- name: Install jql
uses: taiki-e/install-action@v2
with:
tool: jql
- name: Searching for bin
id: searching
run: |
result=$(cargo metadata --format-version=1 --no-deps | jql '"packages"|>"targets"<|[1]|>"kind"' | jql '..' -i);
echo "targets=$result" >> "$GITHUB_OUTPUT";
echo kind of targets "$result";
- name: print if skip upploading binaries to github release
if: ${{ !contains(steps.searching.outputs.targets, 'bin') }}
run: echo "This job avoid publishing binaries to github releases for libraries crates"
outputs:
is_bin: ${{ contains(steps.searching.outputs.targets, 'bin') }}
build:
needs: [create-release, check-if-bin]
if: ${{ needs.check-if-bin.outputs.is_bin == 'true' }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
cross: false
build-tool: cargo
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
features: cross
cross: false
build-tool: cargo
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
cross: true
features: cross
build-tool: cross
- os: ubuntu-latest
target: aarch64-unknown-linux-musl
cross: true
features: cross
build-tool: cross
- os: macos-latest
target: x86_64-apple-darwin
cross: false
build-tool: cargo
- os: macos-latest
target: aarch64-apple-darwin
cross: false
build-tool: cargo
- os: windows-latest
target: x86_64-pc-windows-msvc
cross: false
build-tool: cargo
- os: windows-latest
target: x86_64-pc-windows-gnu
cross: true
build-tool: cargo
- os: windows-latest
target: aarch64-pc-windows-msvc
cross: false
build-tool: cargo
name: ${{ matrix.target }} (${{ matrix.os }})
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Stable Rust Toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
targets: ${{ matrix.target }}
- name: Run sccache-cache
uses: mozilla-actions/[email protected]
env:
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"
- name: Install Dbus
if: ${{ !matrix.cross && startsWith(matrix.os, 'ubuntu-') }}
run: sudo apt update && sudo apt install libdbus-1-dev pkg-config
- name: Install cross-compilation tools
if: ${{ matrix.cross }}
uses: taiki-e/setup-cross-toolchain-action@v1
with:
target: ${{ matrix.target }}
- uses: taiki-e/install-action@v2
if: ${{ matrix.cross }}
with:
tool: cross
- uses: taiki-e/upload-rust-binary-action@v1
with:
bin: ${{ env.BIN_NAME }}
features: ${{ matrix.features || '' }}
# build-tool: ${{ matrix.build-tool }}
target: ${{ matrix.target }}
# include: attribution
archive: $bin-$tag-$target
token: ${{ secrets.GITHUB_TOKEN }}
# ref: refs/tags/${{ needs.get-version.outputs.tag_version }}
checksum: sha256
aur-publish:
runs-on: ubuntu-latest
needs: ["build"]
environment: aur
steps:
- name: Fetch Repository
uses: actions/checkout@v4
- name: Build PKGBUILD
run: |
url="https://github.com/saying121/lcode/releases/download/%s/lcode-%s-%s-unknown-linux-gnu.sha256"
tag=$GITHUB_REF_NAME
# shellcheck disable=SC2059
x86_url=$(printf $url "$tag" "$tag" x86_64)
wget -O x86_64.txt "$x86_url"
# shellcheck disable=SC2059
aarch64_url=$(printf $url "$tag" "$tag" aarch64)
wget -O aarch64.txt "$aarch64_url"
sha_x86_64=$(cut -d' ' -f1 <(cat x86_64.txt))
sha_aarch64=$(cut -d' ' -f1 <(cat aarch64.txt))
sed -i "s/^pkgver=.*/pkgver=$tag/g" ./aur/PKGBUILD
sed -i "s/^sha256sums_x86_64=.*/sha256sums_x86_64=\(\'$sha_x86_64\'\)/g" ./aur/PKGBUILD
sed -i "s/^sha256sums_aarch64=.*/sha256sums_aarch64=\(\'$sha_aarch64\'\)/g" ./aur/PKGBUILD
- name: Publish AUR lcode
uses: KSXGitHub/github-actions-deploy-aur@v2
with:
pkgname: lcode-bin
pkgbuild: ./aur/PKGBUILD
commit_username: ${{ secrets.AUR_USERNAME }}
commit_email: ${{ secrets.AUR_EMAIL }}
ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
commit_message: Update lcode ${{ github.ref_name }}
ssh_keyscan_types: rsa,ecdsa,ed25519