-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from Alokit-Innovations/tr/cicd
Implement github related cicd
- Loading branch information
Showing
4 changed files
with
136 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
|