Skip to content

Commit

Permalink
Merge pull request #4 from Alokit-Innovations/tr/cicd
Browse files Browse the repository at this point in the history
Implement github related cicd
  • Loading branch information
avikalpg authored Sep 18, 2023
2 parents 87ce51d + b4100a0 commit 8f26a9d
Show file tree
Hide file tree
Showing 4 changed files with 136 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Please check the action items covered in the PR -

- [ ] Build is running
- [ ] Eventing is functional and tested
- [ ] Unit or integration tests added and running
- [ ] Manual QA
81 changes: 81 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@

name: Auto-version

on:
pull_request:
types:
- closed

jobs:
build:
if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'main' && github.event.pull_request.head.ref != 'update-cargo-toml'
runs-on: ubuntu-latest

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

- name: Run Build Script
run: |
git config user.name "GitHub Actions Bot"
git config user.email "<>"
- name: run script
run: |
python scripts/update.py
- name: Create Pull Request
uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "Updated code"
title: "Update Cargo.toml"
body: "This pull request updates the Cargo.toml file."
branch: update-cargo-toml
reviewers: tapishr

- name: Build Rust CLI
run: |
cd vibi-dpu
cargo build --release
- name: Get version from Cargo.toml
id: get_version
run: |
cd vibi-dpu
echo "::set-output name=version::$(grep -Po '(?<=version = ")[\d.]+(?=")' Cargo.toml)"
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.get_version.outputs.version }}
release_name: Release ${{ steps.get_version.outputs.version }}
draft: false
prerelease: false

- name: cargo deb
run: |
cargo install cargo-deb
- name: build binary
run: |
cd vibi-dpu
cargo deb
- name: Rename Debian Package
run: mv ./vibi-dpu/target/debian/*.deb ./vibi-dpu/target/debian/vibi-dpu.deb

- name: Upload .deb Package
id: upload_deb
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./vibi-dpu/target/debian/vibi-dpu.deb
asset_name: vibi-dpu.deb
asset_content_type: application/octet-stream

26 changes: 26 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Rust

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

env:
CARGO_TERM_COLOR: always

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Build
run: |
cd vibi-dpu
cargo build --verbose
- name: Run tests
run: |
cd vibi-dpu
cargo test --verbose
23 changes: 23 additions & 0 deletions scripts/update.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

import re
import fileinput

# Read the current version from the Cargo.toml file
current_version = ""
with open("devprofiler/Cargo.toml", "r") as cargo_file:
for line in cargo_file:
match = re.search(r'^version\s*=\s*"(.*?)"', line)
if match:
current_version = match.group(1)
break

# Generate a new version number (increment the patch version)
version_parts = current_version.split('.')
new_patch = int(version_parts[2]) + 1
new_version = f"{version_parts[0]}.{version_parts[1]}.{new_patch}"

# Update the Cargo.toml file with the new version number
for line in fileinput.input("devprofiler/Cargo.toml", inplace=True):
line = re.sub(r'^version\s*=\s*".*?"', f'version = "{new_version}"', line.rstrip())
print(line)

0 comments on commit 8f26a9d

Please sign in to comment.