ci: add release #1
Workflow file for this run
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
name: Release | |
permissions: | |
contents: write | |
on: | |
# release: | |
# types: | |
# - published | |
# - prereleased | |
push: | |
tags: | |
- "v[0-9]+.[0-9]+.[0-9]+" | |
env: | |
BIN_NAME: tidy-borwser | |
PROJECT_NAME: tidy-borwser | |
jobs: | |
create-release: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Release | |
uses: softprops/action-gh-release@v2 | |
if: startsWith(github.ref, 'refs/tags/') | |
with: | |
draft: true | |
# files: | | |
# ${{ env.BIN_NAME }}-*.zip | |
generate_release_notes: true | |
check-if-bin: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Fetch Repository | |
uses: actions/checkout@v4 | |
- name: Install stable toolchain | |
uses: actions-rust-lang/setup-rust-toolchain@v1 | |
- 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 | |
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 | |
with: | |
fetch-depth: 0 | |
- name: Get sha-commit from tag | |
id: get_baseline_sha | |
shell: bash | |
run: | | |
latest_sha=$(git rev-list --tags --max-count=1) | |
echo "sha_tag=$latest_sha" >> "$GITHUB_OUTPUT"; | |
# - name: Install dbus | |
# if: ${{ !matrix.cross && startsWith(matrix.os, 'ubuntu-') }} | |
# run: sudo apt update && sudo apt install libdbus-1-dev pkg-config | |
- name: Checkout source code to specific tag | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ steps.get_baseline_sha.outputs.sha_tag }} | |
- name: Install Nightly Rust Toolchain | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: nightly | |
targets: ${{ matrix.target }} | |
- 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 |