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

Feature/sf main #111

Merged
merged 7 commits into from
Jan 29, 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
7 changes: 7 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
**Do you want to request a *feature* or report a *bug*?**

**What is the current behavior?**

**If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem.**

**What is the expected behavior?**
44 changes: 44 additions & 0 deletions .github/generate_change_log.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env bash

main() {
version="$1"
binaries_dir="$2"

change_log_file="./CHANGELOG.md"
version=`printf "## $version" | tr -d 'v'`
version_prefix="## [0-9]{1,2}\."
start=0
CHANGE_LOG=""
while IFS= read line; do
if [[ $line == *"$version"* ]]; then
start=1
continue
fi
if [[ $line =~ $version_prefix ]] && [ $start == 1 ]; then
break;
fi
if [ $start == 1 ]; then
CHANGE_LOG+="$line\n"
fi
done < ${change_log_file}

LINUX_X86_64_BIN_SUM="$(checksum "$binaries_dir/thegarii-x86_64-unknown-linux-gnu")"

OUTPUT="$(cat <<-END
## Changelog
${CHANGE_LOG}
## Checksums
|Assets | Checksum (sha256)|
|-|-|
|thegarii-x86_64-unknown-linux-gnu | ${LINUX_X86_64_BIN_SUM}|
END
)"

echo -e "${OUTPUT}"
}

checksum() {
echo $(sha256sum $@ | awk '{print $1}')
}

main $@
35 changes: 0 additions & 35 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,35 +0,0 @@
## Changes

<!--

Please provide a brief but specific list of changes made, describe the changes
in functionality rather than the changes in code.

-->

-
-
-

## Tests

<!--

Details on how to run tests relevant to the changes within this pull request.

-->

```

```

## Issues

<!--

Please link any issues that this pull request is related to and use the GitHub
supported format for automatically closing issues (ie, closes #123, fixes #123)

-->

-
13 changes: 13 additions & 0 deletions .github/workflows/audit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# See https://github.com/actions-rs/audit-check
name: Security audit
on:
schedule:
- cron: '0 0 */7 * *'
jobs:
security_audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/audit-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
28 changes: 0 additions & 28 deletions .github/workflows/check-license.yml

This file was deleted.

79 changes: 79 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Continuous Integration

on:
push:
branches: [master, develop]
pull_request:
types: [opened, synchronize, reopened]

env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: full

jobs:
rustfmt:
name: Check rustfmt style
strategy:
matrix:
rust: ["stable"]
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v2

- name: Install Rust Toolchain(s)
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
components: rustfmt
override: true

- name: Cache cargo registry
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
key: rustfmt-cargo-${{ hashFiles('**/Cargo.toml') }}

- name: Check formating
uses: actions-rs/cargo@v1
env:
RUSTFLAGS: "-D warnings"
with:
command: fmt
args: --all -- --check

release-check:
name: Build in release mode
strategy:
matrix:
rust: ["stable"]
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v2

- name: Install Rust Toolchain(s)
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true

- name: Cache cargo registry
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
key: release-cargo-${{ hashFiles('**/Cargo.toml') }}

- name: Cargo check (release)
uses: actions-rs/cargo@v1
env:
RUSTFLAGS: "-D warnings"
with:
command: check
args: --release
173 changes: 173 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
name: Release

on:
push:
tags:
- "*"
workflow_dispatch:

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build:
name: Build Release
runs-on: ubuntu-latest

permissions:
contents: read
packages: write

strategy:
matrix:
rust: [stable]

steps:
- name: Checkout Code
uses: actions/checkout@v2

- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
components: rustfmt
override: true

- uses: actions/cache@v2
name: Cache cargo registry
with:
path: |
~/.cargo/registry
~/.cargo/git
key: release-cargo-${{ hashFiles('**/Cargo.toml') }}

- name: Cache LLVM and Clang
uses: actions/cache@v2
id: cache-llvm
with:
path: |
./llvm
key: llvm-10

- name: Install LLVM and Clang
uses: KyleMayes/install-llvm-action@v1
with:
version: "10"
cached: ${{ steps.cache-llvm.outputs.cache-hit }}

- name: Build target
uses: actions-rs/cargo@v1
env:
CARGO_PROFILE_RELEASE_CODEGEN_UNITS: '1'
CARGO_PROFILE_RELEASE_LTO: 'fat'
with:
# We cannot use `cross` tool right now. The reason is that we require some
# local libraries, `libclang.so` specifically. The `cross` tool runs a Docker
# container which does not have the library in question. We will need to wait to
# have support of https://github.com/cross-rs/cross/pull/635 to be able to cross
# compile properly.
# use-cross: true
command: build
args: --release

- name: Upload Build
uses: actions/upload-artifact@v2
with:
name: linux-x86_64-unknown-linux-gnu
path: ./target/release/thegarii

release:
name: Release
needs: [build]
runs-on: ubuntu-latest

permissions:
contents: write
packages: write

steps:
- name: Set Env
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV

- name: Checkout Code
uses: actions/checkout@v2

- name: Download All Artifacts
id: download-artifacts
uses: actions/download-artifact@v2
with:
path: ./binaries

- name: Sanitize Downloaded Files
run: |
# We downloaded all the artifacts previously uploaded and we put them in
# the 'binaries' folder. In this folder, the layout is:
#
# binaries
# ├── linux-arm64-unknown-linux-gnu
# │ └── <binary>
# └── linux-x86_64-unknown-linux-gnu
# └── <binary>
#
# The sub-folder name comes from the 'name' field of the 'actions/upload-artifact@v2'
# step. The '<binary>' file name is the filename of the uploaded 'path' field,
# we used './target/release/<binary>' in the upload step so the file name here
# is '<binary>'.

download_path="${{steps.download-artifacts.outputs.download-path}}"
chmod +x "${download_path}/linux-x86_64-unknown-linux-gnu/thegarii"
mv "$download_path/linux-x86_64-unknown-linux-gnu/thegarii" "$download_path/thegarii-x86_64-unknown-linux-gnu"

- name: Generate Change Log
id: changelog
if: ${{ startsWith(github.ref, 'refs/tags/') }}
run: |
chmod 755 ./.github/generate_change_log.sh
CHANGELOG=$(./.github/generate_change_log.sh "${{ env.RELEASE_VERSION }}" "${{steps.download-artifacts.outputs.download-path}}")

echo "CHANGELOG<<EOF" >> $GITHUB_ENV
echo "$CHANGELOG" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV

- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Generate docker tags/labels from github build context
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=tag
type=sha,prefix=,enable=true
flavor: |
latest=${{ startsWith(github.ref, 'refs/tags/') }}

- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: ${{steps.download-artifacts.outputs.download-path}}
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

- name: Create Release
uses: softprops/action-gh-release@v1
if: ${{ startsWith(github.ref, 'refs/tags/') }}
with:
name: ${{ env.RELEASE_VERSION }}
tag_name: ${{ env.RELEASE_VERSION }}
draft: false
prerelease: false
body: ${{ env.CHANGELOG }}
token: ${{ secrets.GITHUB_TOKEN }}
fail_on_unmatched_files: true
generate_release_notes: true
files: |
${{steps.download-artifacts.outputs.download-path}}/*
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
arweave.ptr
target
/thegarii
Loading
Loading