ci: rewrite

Rewrite github actions inspirated from 3d2c40ce2f/.github/workflows
This commit is contained in:
MedzikUser 2022-09-21 16:28:47 +02:00
parent e614b64bba
commit b5dd0b3291
No known key found for this signature in database
GPG Key ID: A5FAC1E185C112DB
4 changed files with 171 additions and 95 deletions

View File

@ -1,13 +1,8 @@
name: Build release binaries (and publish them if this is a tag) name: Build release binaries
on: on:
push:
tags:
- "*"
# pull_request:
workflow_dispatch: workflow_dispatch:
workflow_call:
env: env:
CARGO_TERM_COLOR: always CARGO_TERM_COLOR: always
@ -29,7 +24,7 @@ jobs:
include: include:
- os: ubuntu-latest - os: ubuntu-latest
target: x86_64-unknown-linux-musl target: x86_64-unknown-linux-musl
artifact_name: target/x86_64-unknown-linux-musl/release/homedisk artifact_path: target/x86_64-unknown-linux-musl/release/homedisk
release_name: x86_64-unknown-linux-musl release_name: x86_64-unknown-linux-musl
cross: true cross: true
strip: true strip: true
@ -37,7 +32,7 @@ jobs:
- os: ubuntu-latest - os: ubuntu-latest
target: armv7-unknown-linux-musleabihf target: armv7-unknown-linux-musleabihf
artifact_name: target/armv7-unknown-linux-musleabihf/release/homedisk artifact_path: target/armv7-unknown-linux-musleabihf/release/homedisk
release_name: armv7-unknown-linux-musleabihf release_name: armv7-unknown-linux-musleabihf
cross: true cross: true
strip: false strip: false
@ -45,7 +40,7 @@ jobs:
- os: ubuntu-latest - os: ubuntu-latest
target: aarch64-unknown-linux-musl target: aarch64-unknown-linux-musl
artifact_name: target/aarch64-unknown-linux-musl/release/homedisk artifact_path: target/aarch64-unknown-linux-musl/release/homedisk
release_name: aarch64-unknown-linux-musl release_name: aarch64-unknown-linux-musl
cross: true cross: true
strip: false strip: false
@ -53,7 +48,7 @@ jobs:
- os: windows-latest - os: windows-latest
target: x86_64-pc-windows-msvc target: x86_64-pc-windows-msvc
artifact_name: target/x86_64-pc-windows-msvc/release/homedisk.exe artifact_path: target/x86_64-pc-windows-msvc/release/homedisk.exe
release_name: x86_64-pc-windows-msvc.exe release_name: x86_64-pc-windows-msvc.exe
cross: false cross: false
strip: true strip: true
@ -61,7 +56,7 @@ jobs:
- os: macos-latest - os: macos-latest
target: x86_64-apple-darwin target: x86_64-apple-darwin
artifact_name: target/x86_64-apple-darwin/release/homedisk artifact_path: target/x86_64-apple-darwin/release/homedisk
release_name: x86_64-apple-darwin release_name: x86_64-apple-darwin
cross: false cross: false
strip: true strip: true
@ -69,7 +64,7 @@ jobs:
- os: macos-latest - os: macos-latest
target: aarch64-apple-darwin target: aarch64-apple-darwin
artifact_name: target/aarch64-apple-darwin/release/homedisk artifact_path: target/aarch64-apple-darwin/release/homedisk
release_name: aarch64-apple-darwin release_name: aarch64-apple-darwin
cross: false cross: false
strip: true strip: true
@ -102,27 +97,17 @@ jobs:
uses: actions-rs/cargo@v1 uses: actions-rs/cargo@v1
with: with:
command: build command: build
args: --release --target=${{ matrix.target }} ${{ matrix.cargo_flags }} args: --release --target=${{ matrix.target }} ${{ matrix.release_name }}
use-cross: ${{ matrix.cross }} use-cross: ${{ matrix.cross }}
- name: Prepare artifact
shell: bash
run: |
mkdir release
mv ${{ matrix.artifact_path }} release/${{ matrix.artifact_path }}
- name: Upload artifact - name: Upload artifact
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
with: with:
name: ${{ matrix.target }} name: release-${{ matrix.target }}
path: ${{ matrix.artifact_name }} path: ./release/*
- name: Get tag name
id: tag_name
run: |
echo ::set-output name=current_version::${GITHUB_REF#refs/tags/v}
shell: bash
if: startsWith(github.ref, 'refs/tags/v')
- name: Publish
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ matrix.artifact_name }}
tag: ${{ github.ref }}
asset_name: cloud-$tag-${{ matrix.release_name }}
if: startsWith(github.ref, 'refs/tags/v')

101
.github/workflows/ci.yml vendored Normal file
View File

@ -0,0 +1,101 @@
name: Build release binaries (and publish them if this is a tag)
on:
push:
tags:
- "*"
# pull_request:
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
jobs:
build-release:
uses: ./.github/workflows/build_releases.yml
clippy-and-tests:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
rust: [stable, nightly]
name: ${{ matrix.rust }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Rust toolchain
id: rust-toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
components: clippy
- name: Cache
uses: actions/cache@v3
id: cache
with:
path: |
~/.cargo/registry/cache/
target/
key: clippy-test-${{ runner.os }}-${{ matrix.rust }}-${{ steps.rust-toolchain.outputs.rustc_hash }}-${{ hashFiles('**/Cargo.lock') }}
- name: cargo clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --no-deps -- -D warnings
- name: cargo test
uses: actions-rs/cargo@v1
with:
command: test
args: --all-features
upload-release:
runs-on: ubuntu-latest
needs: [build-release]
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Download artifacts
uses: actions/download-artifact@v3
with:
path: ./
- name: Move artifacts
run: |
mkdir release
mv release-*/* release/
- name: Get tag name
id: tag_name
run: |
echo ::set-output name=current_version::${GITHUB_REF#refs/tags/v}
- name: Upload release files
uses: softprops/action-gh-release@17cd0d34deddf848fc0e7d9be5202c148c270a0a # 0.1.14
with:
token: ${{ secrets.GITHUB_TOKEN }}
prerelease: false
tag_name: ${{ github.ref }}
draft: true
fail_on_unmatched_files: true
name: ${{ github.ref }} Release
body: |
<!-- Write summary here -->
---
## Features
## Changes
## Bug Fixes
## Internal Changes
files: |
./release/*

53
.github/workflows/nightly.yml vendored Normal file
View File

@ -0,0 +1,53 @@
name: Nightly
on:
schedule:
- cron: "0 0 * * *"
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
jobs:
build-release:
uses: ./.github/workflows/build_releases.yml
upload-release:
runs-on: ubuntu-latest
needs: [build-release]
steps:
- name: Download artifacts
uses: actions/download-artifact@v3
with:
path: ./
- name: Move artifacts
run: |
mkdir release
mv release-*/* release/
echo "Generated $(ls ./release | wc -l) files:"
du -h -d 0 ./release/*
- name: Delete tag and release
uses: dev-drprasad/delete-tag-and-release@085c6969f18bad0de1b9f3fe6692a3cd01f64fe5 # 0.2.0
with:
delete_release: true
tag_name: nightly
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Sleep for a few seconds to prevent timing issues between the deletion and creation of the release
run: sleep 10
- name: Upload all release files
uses: softprops/action-gh-release@17cd0d34deddf848fc0e7d9be5202c148c270a0a # 0.1.14
with:
token: ${{ secrets.GITHUB_TOKEN }}
prerelease: true
tag_name: "nightly"
draft: false
fail_on_unmatched_files: true
files: |
./release/*

View File

@ -1,63 +0,0 @@
name: Rust
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
jobs:
build:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
rust: [stable, nightly]
name: ${{ matrix.rust }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Rust toolchain
id: rust-toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
components: clippy
- name: Cache
uses: actions/cache@v3
id: cache
with:
path: |
~/.cargo/registry/cache/
target/
key: ${{ runner.os }}-${{ matrix.rust }}-${{ steps.rust-toolchain.outputs.rustc_hash }}-${{ hashFiles('**/Cargo.lock') }}
- name: cargo build
uses: actions-rs/cargo@v1
with:
command: build
- name: cargo clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --no-deps -- -D warnings
- name: cargo test
uses: actions-rs/cargo@v1
with:
command: test
args: --all-features