-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
123 additions
and
6 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,64 @@ | ||
name: Draft Nightly c2ncl | ||
|
||
on: | ||
push: | ||
branches: | ||
- "release-nightly-*" | ||
pull_request: | ||
branches: | ||
- "release-nightly-*" | ||
types: [opened, synchronize, closed] | ||
|
||
env: | ||
CARGO_TERM_COLOR: always | ||
|
||
jobs: | ||
release_image: | ||
runs-on: ubuntu-latest | ||
container: rust:1.69.0-alpine3.17 | ||
|
||
steps: | ||
# Install required dependencies | ||
- name: Install dependencies | ||
run: | | ||
apk add --update alpine-sdk musl-dev g++ make libpq-dev openssl-dev git upx perl build-base dpkg pandoc github-cli | ||
rustup target add x86_64-unknown-linux-musl | ||
- uses: actions/checkout@v3 | ||
# Extract branch info | ||
- name: Set info | ||
run: | | ||
echo "BRANCH_NAME=c2ncl" >> $GITHUB_ENV | ||
echo "CHANNEL=$(echo ${GITHUB_REF##*/} | awk -F- '{print $2}')" >> $GITHUB_ENV | ||
echo "VERSION=$(echo ${GITHUB_REF##*/} | awk -F- '{print $3}')" >> $GITHUB_ENV | ||
# Fix git permission | ||
- name: Fix git permission | ||
run: | | ||
git config --global --add safe.directory /__w/c2ncl/c2ncl | ||
# Print info for debug | ||
- name: Print Info | ||
run: | | ||
echo $BRANCH_NAME | ||
echo $BINARY_NAME | ||
echo $CHANNEL | ||
echo $VERSION | ||
# Package c2ncl into a .deb | ||
- name: Package | ||
run: ./scripts/release_c2ncl.sh | ||
- name: Test if release already exists | ||
id: release-exists | ||
continue-on-error: true | ||
run: gh release view $BINARY_NAME-$VERSION-$CHANNEL | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }} | ||
- name: Create new draft release | ||
if: steps.release-exists.outcome == 'failure' && steps.release-exists.conclusion == 'success' | ||
run: gh release create -d $BINARY_NAME-$VERSION-$CHANNEL -t $BINARY_NAME-$VERSION-$CHANNEL -F changelog.md target/debian/${BINARY_NAME}_${VERSION}_amd64.deb#c2ncl_amd64.deb | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }} | ||
- name: Update draft release | ||
if: steps.release-exists.outcome == 'success' && steps.release-exists.conclusion == 'success' | ||
run: | | ||
gh release delete-asset -y $BINARY_NAME-$VERSION-$CHANNEL ${BINARY_NAME}_${VERSION}_amd64.deb || true | ||
gh release upload $BINARY_NAME-$VERSION-$CHANNEL target/debian/${BINARY_NAME}_${VERSION}_amd64.deb#c2ncl_amd64.deb | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }} |
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 |
---|---|---|
|
@@ -2,8 +2,16 @@ | |
name = "c2ncl" | ||
version = "0.0.1" | ||
edition = "2021" | ||
authors = ["Next Hat Contributors <[email protected]>"] | ||
description = "Converts docker-compose.yml to nanocl StateFile.yml" | ||
readme = "README.md" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
# Profile optimised for binary size | ||
[profile.release] | ||
opt-level = "z" | ||
strip = true | ||
lto = true | ||
codegen-units = 1 | ||
|
||
[dependencies] | ||
anyhow = "1.0.71" | ||
|
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 |
---|---|---|
@@ -1,9 +1,19 @@ | ||
# c2ncl | ||
|
||
Compose to nanocl converts docker-compose file to nanocl config | ||
Convert `docker-compose.yml` to `StateFile.yml` | ||
|
||
## Usage | ||
|
||
```sh | ||
c2ncl -c ../../docker-compose.yml ./example.Statefile | ||
$ c2ncl --help | ||
Converts docker-compose.yml to nanocl StateFile.yml | ||
|
||
Usage: c2ncl [OPTIONS] | ||
|
||
Options: | ||
-i, --in-file <IN_FILE> Path to docker-compose file [default: ./docker-compose.yml] | ||
-o, --out-file <OUT_FILE> Output filepath [default: ./StateFile.yml] | ||
-h, --help Print help | ||
-V, --version Print version | ||
|
||
``` |
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,12 @@ | ||
# Changelog | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | ||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
||
## [0.0.1] 2023-04-30 | ||
|
||
### Added | ||
|
||
- Convert `docker-compose.yml` to `StateFile.yml` |
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 @@ | ||
#!/bin/sh | ||
|
||
# This script is used to release a new version of the project. | ||
|
||
arch=amd64 | ||
pkg_name="c2ncl" | ||
version=$(cat Cargo.toml | grep -m 1 "version = \"" | sed 's/[^0-9.]*\([0-9.]*\).*/\1/') | ||
release_path="./target/${pkg_name}_${version}_${arch}" | ||
|
||
# Clear existing .deb package directory | ||
rm -fr "${release_path}" | ||
# Create new directories structure for .deb package | ||
mkdir -p "${release_path}" | ||
mkdir -p "${release_path}"/DEBIAN | ||
mkdir -p "${release_path}"/usr/local/bin | ||
mkdir -p "${release_path}"/usr/local/man/man1 | ||
|
||
# Build static binary | ||
export RUSTFLAGS="-C target-feature=+crt-static" | ||
cargo build --release --target x86_64-unknown-linux-musl | ||
|
||
# Pack the binary to reduce size | ||
upx --best --lzma ./target/x86_64-unknown-linux-musl/release/${pkg_name} |
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