Skip to content

Commit

Permalink
0.2.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
karamem0 committed Oct 31, 2024
1 parent 3b0085a commit d4d0472
Show file tree
Hide file tree
Showing 11 changed files with 178 additions and 70 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/develop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
on:
push:
branches:
- develop

permissions:
id-token: write
packages: write

jobs:
publish:
name: Publish
uses: ./.github/workflows/publish-ghp.yml
secrets: inherit
with:
environment: dev
16 changes: 16 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
on:
push:
branches:
- main

permissions:
id-token: write
packages: write

jobs:
publish:
name: Publish
uses: ./.github/workflows/publish-ghp.yml
secrets: inherit
with:
environment: prd
37 changes: 37 additions & 0 deletions .github/workflows/publish-ghp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
on:
workflow_call:
inputs:
environment:
required: true
type: string

jobs:
run:
name: Run
runs-on: ubuntu-latest
steps:
- name: Checkout repos
uses: actions/checkout@v4
- name: Setup node.js
uses: actions/setup-node@v4
with:
node-version: 20.x
registry-url: https://npm.pkg.github.com/
always-auth: true
- name: Update package.json
run: npm version ${{vars.BUILD_VERSION}}-${{inputs.environment}}.${{github.run_number}} --no-git-tag-version
- name: Restore source
run: npm ci
- name: Audit source
run: npm audit --omit=dev
- name: Build source
run: npm run build
- name: Create .npmrc
run: |
touch .npmrc
echo "//npm.pkg.github.com/:_authToken=${{secrets.GITHUB_TOKEN}}" >> .npmrc
echo "@karamem0:registry=https://npm.pkg.github.com/" >> .npmrc
- name: Publish source
run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
27 changes: 27 additions & 0 deletions .github/workflows/publish-npm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
on: workflow_call

jobs:
run:
name: Run
runs-on: ubuntu-latest
steps:
- name: Checkout repos
uses: actions/checkout@v4
- name: Setup node.js
uses: actions/setup-node@v4
with:
node-version: 20.x
registry-url: https://registry.npmjs.org/
always-auth: true
- name: Update package.json
run: npm version ${{vars.BUILD_VERSION}} --no-git-tag-version
- name: Restore source
run: npm ci
- name: Audit source
run: npm audit --omit=dev
- name: Build source
run: npm run build
- name: Publish source
run: npm publish --provenance --access=public
env:
NODE_AUTH_TOKEN: ${{secrets.NODE_AUTH_TOKEN}}
11 changes: 11 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
on: workflow_call

jobs:
run:
name: Run
runs-on: ubuntu-latest
steps:
- name: Create release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
14 changes: 14 additions & 0 deletions .github/workflows/tags.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
on:
push:
tags:
- v*.*.*

jobs:
publish:
name: Publish
uses: ./.github/workflows/publish-npm.yml
secrets: inherit
release:
name: Release
uses: ./.github/workflows/release.yml
secrets: inherit
66 changes: 0 additions & 66 deletions .github/workflows/workflow.yml

This file was deleted.

3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,11 @@
npx zenn-emoji articles/* -u
```
既定ではアイキャッチ絵文字が空欄の場合のみ更新します。アイキャッチ絵文字が設定されているファイルも更新したい場合は `-f` オプションを追加してください。
## オプション
|短い名前|長い名前|説明|
|-|-|-|
|`-u`|`--update`|対象のファイルを更新します。|
|`-f`|`--force`|アイキャッチ絵文字が設定されているファイルの更新を強制します。|
11 changes: 10 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ dotenv.config({ path: ['.env', '.env.local'] });
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

interface Option {
force: boolean,
update: boolean
}

function createOpenAI(): OpenAI {
if (process.env.OPENAI_API_KEY) {
return new OpenAI({
Expand Down Expand Up @@ -64,13 +69,17 @@ function createOpenAI(): OpenAI {
program
.version(process.env.npm_package_version)
.argument('<files...>', 'The target files')
.option('-f, --force', 'Force to update the target files')
.option('-u, --update', 'Update the target files')
.action(async (files: string[], option: { update: boolean }) => {
.action(async (files: string[], option: Option) => {
const prompt = await fs.promises.readFile(path.join(__dirname, 'skills/skprompt.txt'), 'utf-8');
const openai = createOpenAI();
files.forEach(async (file) => {
try {
const text = await fs.promises.readFile(file, 'utf-8');
if (!option.force && /emoji: ".+"/u.test(text)) {
return;
}
const completion = await openai.chat.completions.create(
{
messages: [
Expand Down
41 changes: 41 additions & 0 deletions test/articles/ebd6b7f4e118f3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
title: "ハンズオンで学ぶ C# プログラミング"
emoji: ""
type: "tech"
topics: []
published: false
---

# はじめに

皆さんこんにちは!今日は、C# プログラミングの基本を学ぶハンズオン記事をお届けします。C# は、Microsoft が開発した強力なプログラミング言語であり、特に Windows アプリケーションやゲーム開発でよく使われます。

# 準備

まず、開発環境を整えましょう。Visual Studio をインストールし、C# プロジェクトを新規作成します。

1. Visual Studio を開く
2. 新規プロジェクトを選択
3. C# コンソールアプリケーションを選ぶ

# 基本の Hello World

C# の基本を学ぶために、まずは **Hello World** プログラムを作成します。以下のコードを入力してみてください。

```csharp
using System;

class Program
{
static void Main()
{
Console.WriteLine("Hello, World!");
}
}
```

このコードを実行すると、コンソールに `Hello, World!` と表示されます。

# まとめ

これが、C# プログラミングの始めの一歩です。この後も、変数や条件分岐、ループ構造などを学んでいきますので、お楽しみに!次回の記事では、もう少し複雑なプログラムに挑戦してみましょう。
6 changes: 3 additions & 3 deletions test/package-lock.json

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

0 comments on commit d4d0472

Please sign in to comment.