Skip to content

Commit

Permalink
feat: initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
kirinnee committed Jan 10, 2025
1 parent 86cdefe commit 2556745
Show file tree
Hide file tree
Showing 19 changed files with 212 additions and 39 deletions.
Binary file modified cyan/bun.lockb
Binary file not shown.
36 changes: 32 additions & 4 deletions cyan/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,40 @@
import { StartTemplateWithLambda } from '@atomicloud/cyan-sdk';
import { Cyan, GlobType, IDeterminism, IInquirer, StartTemplateWithLambda } from '@atomicloud/cyan-sdk';

StartTemplateWithLambda(async (i: IInquirer, d: IDeterminism): Promise<Cyan> => {
const name = await i.text('Name', "Nuget Package's Name. Please use Pascal Case");

const platform = await i.text('Platform', "AtomiCloud LPSM Service Tree's Platform");
const service = await i.text('Service', "AtomiCloud LPSM Service Tree's Service");

const capitalize = (s: string) => s.charAt(0).toUpperCase() + s.slice(1);
const namespace = capitalize(platform) + capitalize(service);

const desc = await i.text('Description', "Nuget Package's Description");

StartTemplateWithLambda(async (i, d) => {
return {
processors: [
{
name: 'cyan/default',
files: [],
config: {},
files: [
{
glob: '**/*',
root: 'template',
type: GlobType.Template,
exclude: [],
},
],
config: {
vars: {
name,
platform,
service,
namespace,
desc,
},
parser: {
varSyntax: [['let___', '___']],
},
},
},
],
plugins: [],
Expand Down
3 changes: 3 additions & 0 deletions template/.github/actionlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
self-hosted-runner:
labels:
- '*'
45 changes: 43 additions & 2 deletions template/.github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,38 @@ jobs:
# pre commit
- name: Run pre-commit
run: nix develop .#ci -c ./scripts/ci/pre-commit.sh
publish:
name: Publish Current Commit
runs-on:
- nscloud-ubuntu-22.04-amd64-4x8-with-cache
- nscloud-cache-size-50gb
- nscloud-cache-tag-let___platform___-let___service___-publish-nuget-cache
- nscloud-git-mirror-1gb
steps:
# Setup
- uses: AtomiCloud/actions.setup-nix@v1.2.1
- uses: AtomiCloud/actions.cache-nuget@v1.0.1

# Publish
- uses: rlespinasse/github-slug-action@v5.x
with:
short-length: 7
- name: Publish
env:
GITHUB_REPO_REF: ${{ github.repository }}
GITHUB_SHA: ${{ github.sha }}
GITHUB_BRANCH: ${{ env.GITHUB_REF_SLUG_URL }}

RELEASE: 'false'

NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
run: nix develop .#ci -c scripts/ci/publish.sh

release:
name: Semantic Release
needs:
- precommit
- publish

if: github.ref == 'refs/heads/main'
runs-on:
Expand All @@ -40,10 +67,24 @@ jobs:
# action
- uses: rlespinasse/github-slug-action@v5.x
with:
short-length: 8
short-length: 7
- name: Release
env:
# needed for releaser
GITHUB_REPO_REF: ${{ github.repository }}
GITHUB_SHA: ${{ github.sha }}
GITHUB_BRANCH: ${{ env.GITHUB_REF_SLUG_URL }}

GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

run: nix develop .#releaser -c scripts/ci/release.sh
- name: Publish
env:
GITHUB_REPO_REF: ${{ github.repository }}
GITHUB_SHA: ${{ github.sha }}
GITHUB_BRANCH: ${{ env.GITHUB_REF_SLUG_URL }}

RELEASE: 'true'
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
run: nix develop .#ci -c scripts/ci/publish.sh
8 changes: 8 additions & 0 deletions template/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
obj
bin
Chsarpier
.DS_Store
.env
.idea
.direnv
.pre-commit-config.yaml
7 changes: 7 additions & 0 deletions template/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright 2025 AtomiCloud

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
9 changes: 9 additions & 0 deletions template/README.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# let___name___

let___desc___

# Installation

```bash
dotnet add package AtomiCloud.let___name___
```
7 changes: 7 additions & 0 deletions template/atomi_release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ plugins:
config:
changelogFile: Changelog.md

# update version
- module: '@semantic-release/exec'
version: 6.0.3
config:
prepareCmd: scripts/ci/update_version.sh ${nextRelease.version}

# Commit Additional Changes & Artifacts
- module: '@semantic-release/git'
version: 10.0.1
Expand All @@ -36,6 +42,7 @@ plugins:
assets:
- Changelog.md
- docs/developer/CommitConventions.md
- lib/lib.csproj

# Github Release
- module: '@semantic-release/github'
Expand Down
8 changes: 4 additions & 4 deletions template/flake.lock

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

2 changes: 1 addition & 1 deletion template/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# registry
nixpkgs.url = "nixpkgs/nixos-unstable";
nixpkgs-2411.url = "nixpkgs/nixos-24.11";
atomipkgs.url = "github:AtomiCloud/nix-registry/v1.0.0";
atomipkgs.url = "github:AtomiCloud/nix-registry/v1";

};
outputs =
Expand Down
22 changes: 22 additions & 0 deletions template/lib.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "lib", "lib\lib.csproj", "{1B2C2CFB-A0EE-4782-B502-A604FB121D4D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{1B2C2CFB-A0EE-4782-B502-A604FB121D4D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1B2C2CFB-A0EE-4782-B502-A604FB121D4D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1B2C2CFB-A0EE-4782-B502-A604FB121D4D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1B2C2CFB-A0EE-4782-B502-A604FB121D4D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
Binary file added template/lib/Assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions template/lib/Class1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace let___namespace___;

public class Class1
{

}
22 changes: 22 additions & 0 deletions template/lib/lib.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<RootNamespace>let___namespace___</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Description>let___desc___</Description>
<PackageIcon>logo.png</PackageIcon>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<RepositoryUrl>RepositoryUrl</RepositoryUrl>
<Authors>Ernest Ng</Authors>
<VersionPrefix>1.0.0</VersionPrefix>
<PackageId>AtomiCloud.let___name___</PackageId>
<PackageReadmeFile>README.MD</PackageReadmeFile>
</PropertyGroup>
<ItemGroup>
<None Include="..\README.MD" Pack="true" PackagePath="\"/>
<None Include="..\LICENSE" Pack="true" PackagePath="\"/>
<None Include="Assets\logo.png" Pack="true" PackagePath="\"/>
</ItemGroup>
</Project>
20 changes: 5 additions & 15 deletions template/nix/fmt.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,11 @@ let

# enable or disable formatters, see https://github.com/numtide/treefmt-nix#supported-programs
programs = {
nixpkgs-fmt = {
enable = true;
};
prettier = {
enable = true;
};
shfmt = {
enable = true;
};
csharpier = {
enable = true;
};
actionlint = {
enable = true;
};
nixpkgs-fmt.enable = true;
prettier.enable = true;
shfmt.enable = true;
csharpier.enable = true;
actionlint.enable = true;
};
};
in
Expand Down
9 changes: 1 addition & 8 deletions template/nix/packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,14 @@ let
yq = yq-go;
dotnet = dotnet-sdk_9;

/*
*/

inherit

# standard
coreutils
findutils
gnugrep
gnused
gcc
jq
bash

Expand All @@ -41,10 +38,6 @@ let
treefmt
gitlint
shellcheck

/*
*/
;
}
);
Expand Down
10 changes: 5 additions & 5 deletions template/nix/pre-commit.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ pre-commit-lib.run {
enable = false;
};

a-dotnet-lint-app = {
a-dotnet-lint-lib = {
enable = true;
name = "Lint .NET 'App' Project";
description = "Run formatter for .NET Project 'App'";
entry = "${packages.dotnet}/bin/dotnet format style --no-restore --severity info --verify-no-changes -v d ./App/App.csproj";
name = "Lint .NET 'Lib' Project";
description = "Run formatter for .NET Project 'Lib'";
entry = "${packages.dotnet}/bin/dotnet format style --no-restore --severity info --verify-no-changes -v d ./lib/lib.csproj";
language = "system";
pass_filenames = false;
files = "^App/.*\\.cs$";
files = "^lib/.*\\.cs$";
};

a-infisical = {
Expand Down
30 changes: 30 additions & 0 deletions template/scripts/ci/publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env bash

[ "${RELEASE}" = '' ] && echo "❌ 'RELEASE' env var not set" && exit 1

[ "${GITHUB_SHA}" = '' ] && echo "❌ 'GITHUB_SHA' env var not set" && exit 1
[ "${GITHUB_BRANCH}" = '' ] && echo "❌ 'GITHUB_BRANCH' env var not set" && exit 1
[ "${GITHUB_REPO_REF}" = '' ] && echo "❌ 'GITHUB_REPO_REF' env var not set" && exit 1

[ "${NUGET_API_KEY}" = '' ] && echo "❌ 'NUGET_API_KEY' env var not set" && exit 1

set -eou pipefail

SHA="$(echo "${GITHUB_SHA}" | head -c 6)"
# shellcheck disable=SC2001
BRANCH="$(echo "${GITHUB_BRANCH}" | sed 's/[._-]*$//')"
RELEASE_VERSION="${BRANCH}-${SHA}"

echo "🪵 Current Branch: $BRANCH"

if [ "${RELEASE}" == "true" ]; then
echo "🔍 Full release detected, building with version"
dotnet pack ./lib/lib.csproj --output nupkgs
else
echo "🔍 Pre-release detected, building with version suffix, $RELEASE_VERSION"
dotnet pack ./lib/lib.csproj --version-suffix "$RELEASE_VERSION" --output nupkgs
fi

echo "📦 Publishing packages..."
dotnet nuget push ./nupkgs/*.nupkg --api-key "${NUGET_API_KEY}" --source "https://api.nuget.org/v3/index.json" --skip-duplicate
echo "✅ Packages published!"
7 changes: 7 additions & 0 deletions template/scripts/ci/update_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

version="$1"

set -eou pipefail

xmlstarlet ed -L -u '//Project/PropertyGroup/VersionPrefix' -v "$version" ./lib/lib.csproj

0 comments on commit 2556745

Please sign in to comment.