Skip to content

Commit

Permalink
add workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
QaidVoid committed Dec 5, 2024
1 parent e25124e commit 782aa33
Show file tree
Hide file tree
Showing 9 changed files with 329 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
19 changes: 19 additions & 0 deletions .github/workflows/auto-assign.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Auto Assign
on:
issues:
types: [opened]
pull_request:
types: [opened]
jobs:
run:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- name: 'Auto-assign issue'
uses: pozil/auto-assign-issue@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
assignees: QaidVoid
numOfAssignee: 1
86 changes: 86 additions & 0 deletions .github/workflows/nightly.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: soar-dl nightly

on:
push:
branches:
- main
workflow_dispatch:

permissions:
contents: write

jobs:
remove-nightly-tag:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Remove existing nightly tag
run: |
gh release delete nightly --cleanup-tag || true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish-nightly:
name: Publish nightly binaries
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
build:
- {
NAME: x86_64-linux,
TARGET: x86_64-unknown-linux-musl,
}
- {
NAME: aarch64-linux,
TARGET: aarch64-unknown-linux-musl,
}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Get version info
id: version
run: |
SHORT_SHA=$(git rev-parse --short HEAD)
echo "version=nightly-${SHORT_SHA}" >> $GITHUB_OUTPUT
- name: Install dependencies
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
--allow-unauthenticated musl-tools b3sum
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.build.TARGET }}

- name: Install cross-compilation tools
uses: taiki-e/setup-cross-toolchain-action@v1
with:
target: ${{ matrix.build.TARGET }}

- name: Build
run: SOAR_NIGHTLY=1 cargo build --release --locked --target ${{ matrix.build.TARGET }}

- name: Prepare nightly binary
shell: bash
run: |
mkdir -p nightly
cp "target/${{ matrix.build.TARGET }}/release/soar-dl" nightly/soar-dl-nightly-${{ matrix.build.NAME }}
b3sum nightly/soar-dl-nightly-${{ matrix.build.NAME }} > nightly/soar-dl-nightly-${{ matrix.build.NAME }}.b3sum
- name: Upload nightly binary
uses: softprops/action-gh-release@v2
with:
files: nightly/*
tag_name: nightly
name: ${{ steps.version.outputs.version }}
body: "This is an automated nightly build of soar-dl."
prerelease: true
draft: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
112 changes: 112 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
name: soar-dl release

on:
push:
tags:
- "v*.*.*"
permissions:
contents: write

jobs:
generate-changelog:
name: Generate changelog
runs-on: ubuntu-latest
outputs:
release_body: ${{ steps.git-cliff.outputs.content }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Generate a changelog
uses: orhun/git-cliff-action@main
id: git-cliff
with:
config: cliff.toml
args: -vv --latest --no-exec --github-repo ${{ github.repository }}
publish-binaries:
name: Publish binaries
needs: generate-changelog
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
build:
- {
NAME: x86_64-linux,
TARGET: x86_64-unknown-linux-musl,
}
- {
NAME: aarch64-linux,
TARGET: aarch64-unknown-linux-musl,
}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set the release version
shell: bash
run: echo "RELEASE_VERSION=${GITHUB_REF:11}" >> $GITHUB_ENV

- name: Install dependencies
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
--allow-unauthenticated musl-tools b3sum
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.build.TARGET }}

- name: Install cross-compilation tools
uses: taiki-e/setup-cross-toolchain-action@v1
with:
target: ${{ matrix.build.TARGET }}

- name: Build
run: cargo build --release --locked --target ${{ matrix.build.TARGET }}

- name: Prepare release assets
shell: bash
run: |
mkdir -p release
cp {LICENSE,README.md,CHANGELOG.md} release/
cp "target/${{ matrix.build.TARGET }}/release/soar-dl" release/
- name: Create release artifacts
shell: bash
run: |
cp release/soar-dl soar-dl-${{ matrix.build.NAME }}
b3sum soar-dl-${{ matrix.build.NAME }} \
> soar-dl-${{ matrix.build.NAME }}.b3sum
tar -czvf soar-dl-${{ matrix.build.NAME }}.tar.gz \
release/
b3sum soar-dl-${{ matrix.build.NAME }}.tar.gz \
> soar-dl-${{ matrix.build.NAME }}.tar.gz.b3sum
- name: Publish to GitHub
if: ${{ !contains(github.ref, '-') }}
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: soar-dl-${{ matrix.build.NAME }}*
file_glob: true
overwrite: true
tag: ${{ github.ref }}
release_name: "soar-dl v${{ env.RELEASE_VERSION }}"
body: "${{ needs.generate-changelog.outputs.release_body }}"

- name: Publish to GitHub (pre-release)
if: ${{ contains(github.ref, '-') }}
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: soar-dl-${{ env.RELEASE_VERSION }}-${{ matrix.build.NAME }}*
file_glob: true
overwrite: true
tag: ${{ github.ref }}
release_name: "Pre-release v${{ env.RELEASE_VERSION }}"
prerelease: true
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Changelog

## [0.1.1] - 2024-12-05

### Added

- Add workflow

### Changed

- Handle tags
- Initialize soar-dl
- Initial commit


<!-- generated by git-cliff -->
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "soar-dl"
version = "0.1.0"
version = "0.1.1"
authors = ["Rabindra Dhakal <contact@qaidvoid.dev>"]
description = "A fast download manager"
license = "MIT"
Expand Down
21 changes: 21 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
use std::process::Command;

fn main() {
if std::env::var("SOAR_NIGHTLY").is_ok() {
let commit_sha = Command::new("git")
.arg("rev-parse")
.arg("--short")
.arg("HEAD")
.output()
.expect("Failed to get git commit SHA")
.stdout;

let commit_sha = String::from_utf8(commit_sha)
.expect("Invalid UTF-8 output")
.trim()
.to_string();

println!("cargo:rerun-if-changed=build.rs");
println!("cargo:rustc-env=CARGO_PKG_VERSION=nightly-{}", commit_sha);
}
}
67 changes: 67 additions & 0 deletions cliff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# git-cliff ~ configuration file
# https://git-cliff.org/docs/configuration

[changelog]
# template for the changelog header
header = """
# Changelog\n
"""
# template for the changelog body
# https://keats.github.io/tera/docs/#introduction
body = """
{% if version -%}
## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
{% else -%}
## [Unreleased]
{% endif -%}
{% for group, commits in commits | group_by(attribute="group") %}
### {{ group | upper_first }}
{% for commit in commits %}
- {{ commit.message | split(pat="\n") | first | upper_first | trim }}\
{% endfor %}
{% endfor %}\n
"""
# template for the changelog footer
footer = """
{% for release in releases -%}
{% if release.version -%}
{% if release.previous.version -%}
[{{ release.version | trim_start_matches(pat="v") }}]: \
https://github.com/{{ remote.github.owner }}/{{ remote.github.repo }}\
/compare/{{ release.previous.version }}..{{ release.version }}
{% endif -%}
{% else -%}
[unreleased]: https://github.com/{{ remote.github.owner }}/{{ remote.github.repo }}\
/compare/{{ release.previous.version }}..HEAD
{% endif -%}
{% endfor %}
<!-- generated by git-cliff -->
"""
# remove the leading and trailing whitespace from the templates
trim = true

[git]
# parse the commits based on https://www.conventionalcommits.org
conventional_commits = true
# filter out the commits that are not conventional
filter_unconventional = false
# regex for parsing and grouping commits
commit_parsers = [
{ message = "^[a|A]dd", group = "Added" },
{ message = "^[s|S]upport", group = "Added" },
{ message = "^[r|R]emove", group = "Removed" },
{ message = "^.*: add", group = "Added" },
{ message = "^.*: support", group = "Added" },
{ message = "^.*: remove", group = "Removed" },
{ message = "^.*: delete", group = "Removed" },
{ message = "^test", group = "Fixed" },
{ message = "^fix", group = "Fixed" },
{ message = "^.*: fix", group = "Fixed" },
{ message = "^.*", group = "Changed" },
]
# filter out the commits that are not matched by commit parsers
filter_commits = false
# sort the tags topologically
topo_order = false
# sort the commits inside sections by oldest/newest order
sort_commits = "newest"

0 comments on commit 782aa33

Please sign in to comment.