Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add action to build and release project #1

Merged
merged 1 commit into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .github/actions/archive/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Create Archive
description: Create archive containing build artifacts
inputs:
target:
description: Target to build for
required: true
outputs:
archive_name:
description: Name of the archive
value: ${{ steps.create-artifact-archive.outputs.archive_name}}
short_sha:
description: Shorthash
value: ${{ steps.create-artifact-archive.outputs.short_sha }}
runs:
using: "composite"
steps:
- name: Create Artifact Archive
env:
TARGET: ${{ inputs.target }}
shell: bash
run: |
export sha_short=$(git rev-parse --short "$GITHUB_SHA")
[[ -z $sha_short ]] && sha_short="unknown"
echo "sha_short=$sha_short" >> "$GITHUB_OUTPUT"

export archive_name="conUDS_$sha_short_${{ inputs.target }}.zip"
echo "archive_name=$archive_name" >> "$GITHUB_OUTPUT"

printf "\n📦 Creating the archive...\n"

cp "./conUDS/target/${{ inputs.target }}/release/conUDS" "./conUDS/"
zip -r "$archive_name" "./conUDS/assets/" "./conUDS/conUDS" || { printf "\n⛔ Unable to create tar archive.\n"; exit 1; }
sha256sum $archive_name > CHECKSUM
rm "./conUDS/conUDS"

printf "\n✔ Successfully created the archive.\n"
23 changes: 23 additions & 0 deletions .github/actions/build-rust/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Build Rust Project
description: Build Rust Project
inputs:
target:
description: Target to build for
required: true
runs:
using: "composite"
steps:
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
target: ${{ inputs.target }}
- uses: Swatinem/rust-cache@v2
with:
save-if: ${{ github.ref == 'refs/heads/main' }}
workspaces: |
./conUDS -> ./conUDS/target
- uses: actions-rs/cargo@v1
with:
command: build
args: --release --manifest-path ./conUDS/Cargo.toml --target ${{ inputs.target }}
44 changes: 44 additions & 0 deletions .github/workflows/artifacts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
on: [push]
name: Build
jobs:
build_and_upload:
name: Build
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
target: [x86_64-unknown-linux-gnu]
env:
CARGO_TERM_COLOR: always
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/build-rust
with:
target: ${{ matrix.target }}
- name: Copy Binary and SHA256
shell: bash
run: |
cp "./conUDS/target/${{ matrix.target }}/release/conUDS" "./conUDS/"
export sha_short=$(git rev-parse --short "$GITHUB_SHA")
[[ -z $sha_short ]] && sha_short="unknown"
echo "sha_short=$sha_short" >> "$GITHUB_ENV"
- uses: actions/upload-artifact@v3
with:
name: conUDS_${{ env.sha_short }}
path: |
./conUDS/assets
./conUDS/conUDS
if-no-files-found: error
- name: Generate Archive Checksum
shell: bash
run: |
ls -lap
sha256sum ./conUDS/conUDS >> CHECKSUM
sha256sum ./conUDS/assets/nodes.yml >> CHECKSUM
cat CHECKSUM
- uses: actions/upload-artifact@v3
with:
name: CHECKSUM
path: |
./CHECKSUM
if-no-files-found: error
45 changes: 45 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
on:
push:
branches:
- main
name: Auto Release
jobs:
build_and_release:
name: Build
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
target: [x86_64-unknown-linux-gnu]
env:
CARGO_TERM_COLOR: always
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/build-rust
with:
target: ${{ matrix.target }}
- name: Create Artifact Archive
uses: ./.github/actions/archive
with:
target: ${{ matrix.target }}
# make pre-release for regular pushes
- if: ${{ ! startsWith(github.ref, 'refs/tags/v') }}
uses: marvinpinto/[email protected]
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "latest"
prerelease: true
title: "Development Build"
files: |
${{ steps.create-artifact-archive.archive_name }}
CHECKSUM
# make a real release if there's a tag
- if: ${{ startsWith(github.ref, 'refs/tags/v') }}
uses: marvinpinto/[email protected]
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: false
title: "Release ${{ github.ref_name }}"
files: |
${{ steps.create-artifact-archive.archive_name }}
CHECKSUM
4 changes: 4 additions & 0 deletions conUDS/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ name = "conuds"
version = "0.1.0"
edition = "2021"

[[bin]]
name = "conUDS"
path = "src/main.rs"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
Expand Down
Loading