Skip to content

Commit

Permalink
Merge pull request #207 from Candinya/v3
Browse files Browse the repository at this point in the history
V3
  • Loading branch information
Candinya committed May 31, 2024
2 parents 13c0d44 + 06365c1 commit 60cefd6
Show file tree
Hide file tree
Showing 426 changed files with 17,052 additions and 349,879 deletions.
91 changes: 0 additions & 91 deletions .demo/_config.kratos-rebirth.yml

This file was deleted.

7 changes: 0 additions & 7 deletions .github/dependabot.yml

This file was deleted.

40 changes: 35 additions & 5 deletions .github/workflows/auto-release.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,49 @@
name: Release events
name: Auto Release

on:
push:
tags:
- 'v*'

jobs:
gpr_publish:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
registry-url: 'https://registry.npmjs.org'
- name: Publish to NPM

- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9

- name: Install deps
run: pnpm install --frozen-lockfile

- name: Build
run: pnpm build

- name: Publish stable release version (with default latest tag)
if: ${{ ! contains(github.ref_name, '-') }}
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN_CANDINYA }}

- name: Publish unstable pre-release version (with next tag)
if: ${{ contains(github.ref_name, '-') }} # Refer to Semantic Versioning , use a hyphen to split version code and pre-release identifier
run: npm publish --tag next
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN_CANDINYA }}

- name: Create release (draft)
uses: softprops/action-gh-release@v2
with:
name: "[${{ github.ref_name }}] (新的发布)"
generate_release_notes: true
draft: true
prerelease: ${{ contains(github.ref_name, '-') }}
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
117 changes: 58 additions & 59 deletions .github/workflows/build-demo.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,28 @@
# Build the demo site when new changes are commited.

name: Build Demo Site

# This will run when push events occur on master branch.
on:
push:
branches: [ master ]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of container that the job will run in
runs-on: ubuntu-latest

# Environment virables
env:
SITE_URL: kr-demo.candinya.com

# Steps represent a sequence of tasks that will be executed as part of the job
steps:

# Setup Node.js env
- uses: actions/setup-node@v2.1.2
- uses: actions/setup-node@v4
with:
node-version: '16.x'

node-version: 'lts'

- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9
run_install: false

# Get Hexo test utils
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
repository: 'hexojs/hexo-theme-unit-test'

Expand All @@ -36,75 +31,79 @@ jobs:
run: mkdir themes

# Clone Kratos-Rebirth into themes dir
- name: Clone Kratos-Rebirth into themes dir
run: git clone --single-branch --branch master https://github.com/${GITHUB_REPOSITORY} ./themes/kratos-rebirth
- uses: actions/checkout@v4
with:
path: 'themes/kratos-rebirth'

# Clone Demo site configurations & assets into tmp
- uses: actions/checkout@v4
with:
repository: 'kratos-rebirth/demo-site-v3'
path: '/tmp/demo-site'

# Build fresh theme files
- name: Build theme files
run: |
cd ./themes/kratos-rebirth
pnpm install --frozen-lockfile
pnpm build
# Edit hexo site settings
- name: Edit Hexo site settings
run: |
sed -i "s/title: Hexo/title: Kratos-Rebirth/" "_config.yml"
sed -i "s/subtitle: ''/subtitle: A demo site of theme Kratos Rebirth/" "_config.yml"
sed -i "s/description: ''/description: A demo site of theme Kratos Rebirth/" "_config.yml"
sed -i "s/title: Hexo/title: 'Kratos : Rebirth'/" "_config.yml"
sed -i "s/subtitle: ''/subtitle: 一个可爱而现代的 Hexo 主题/" "_config.yml"
sed -i "s/description: ''/description: 欢迎使用这个主题,希望能给您带来美好的体验。/" "_config.yml"
sed -i "s/author: John Doe/author: Candinya/" "_config.yml"
sed -i "s/language:/language: zh-CN/" "_config.yml"
sed -i "s|url: http://yoursite.com|url: https://${SITE_URL}|" "_config.yml"
sed -i "s|url: http://example.com|url: https://demo.krt.moe|" "_config.yml"
sed -i "s|permalink: :year/:month/:day/:title/|permalink: posts/:title/|" "_config.yml"
sed -i "s/theme: landscape/theme: kratos-rebirth/" "_config.yml"
# Copy document
- name: Copy document
run: cp "themes/kratos-rebirth/Kratos-Rebirth-Manual.md" "source/_posts/Kratos-Rebirth-Manual.md"

# Pin document
- name: Pin document
run: |
sed '2 isticky: 1' -i source/_posts/Kratos-Rebirth-Manual.md
# Copy extended theme settings
- name: Copy extended theme settings
run: cp "themes/kratos-rebirth/.demo/_config.kratos-rebirth.yml" "_config.kratos-rebirth.yml"

run: mv "/tmp/demo-site/_config.kratos-rebirth.yml" "_config.kratos-rebirth.yml"

# Prepare assets
- name: Prepare assets
run: mv /tmp/demo-site/assets source/demo-assets

# Edit theme settings
- name: Edit theme settings
run: |
sed -i "s|clientID: 'GitHub Application Client ID'|clientID: ${{ secrets.GH_OAUTH_ID }}|" "_config.kratos-rebirth.yml"
sed -i "s|clientSecret: 'GitHub Application Client Secret'|clientSecret: ${{ secrets.GH_OAUTH_SECRET }}|" "_config.kratos-rebirth.yml"
# Set Pages CNAME file
- name: Set github pages CNAME file
run: |
touch "source/CNAME"
echo "${SITE_URL}" > source/CNAME
# Install Hexo env
- name: Install Hexo environment
run: npm install

# Install post-time-fix plugin
- name: Install post-time-fix plugin
run: npm install hexo-filter-date-from-git --save

# Setup git configs
- name: Setup git configs
run: |
git config --global user.name "Github Actions"
git config --global user.email "[email protected]"
# Set private key for deployment
mkdir -p ~/.ssh/
echo "${{ secrets.DEPLOY_KEY }}" | tr -d '\r' > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan github.com >> ~/.ssh/known_hosts

# Hexo build demo site
- name: Hexo build demo site
run: npx hexo generate --force

# Deploy demo site
- name: Deploy demo site
run: |
cd ./public
git init -b gh-pages
git remote add origin [email protected]:Candinya/Kratos-Rebirth-Demo.git
git add -A
git commit -m "Update Demo Site at `date +'%Y-%m-%d %H:%M:%S'`"
git push --set-upstream origin gh-pages -f

- name: Upload artifacts for pages
uses: actions/upload-pages-artifact@v3
with:
path: public

deploy:
needs: build

permissions:
pages: write
id-token: write

environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
39 changes: 30 additions & 9 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,32 @@

name: Build Test

on: pull_request
on:
pull_request:

jobs:
build:
strategy:
matrix:
node-version: [18, 20, 22]

runs-on: ubuntu-latest

steps:

# Setup Node.js env
- uses: actions/[email protected]
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Install pnpm
uses: pnpm/action-setup@v4
with:
node-version: '14.x'
version: 9
run_install: false

# Get Hexo test utils
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
repository: 'hexojs/hexo-theme-unit-test'

Expand All @@ -25,19 +36,22 @@ jobs:
run: mkdir themes

# Clone Kratos-Rebirth into themes dir
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
path: 'themes/kratos-rebirth'

# Build fresh theme files
- name: Build theme files
run: |
cd ./themes/kratos-rebirth
pnpm install --frozen-lockfile
pnpm build
# Edit hexo site settings
- name: Edit Hexo Theme settings
run: |
sed -i "s/language:/language: zh-CN/" "_config.yml"
sed -i "s/theme: landscape/theme: kratos-rebirth/" "_config.yml"
# Copy theme settings
- name: Copy theme settings
run: cp "themes/kratos-rebirth/.demo/_config.kratos-rebirth.yml" "_config.kratos-rebirth.yml"
# Install Hexo env
- name: Install Hexo environment
Expand All @@ -46,3 +60,10 @@ jobs:
# Hexo build demo site
- name: Hexo build test
run: npx hexo generate

- name: Upload built as artifacts
uses: actions/upload-artifact@v4
with:
name: test-node${{ matrix.node-version }}
path: public
retention-days: 1
Loading

0 comments on commit 60cefd6

Please sign in to comment.