Skip to content

Commit

Permalink
feat: first commit
Browse files Browse the repository at this point in the history
Signed-off-by: thxCode <[email protected]>
  • Loading branch information
thxCode committed Jan 8, 2024
0 parents commit c53bdc8
Show file tree
Hide file tree
Showing 55 changed files with 5,149 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .commitsar.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
commits:
disabled: false
strict: false
limit: 100
all: false
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
* text=auto eol=lf

**/*.pb.go linguist-generated=true
staging/**/go.sum linguist-generated=true
122 changes: 122 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
name: ci

permissions:
contents: read
pull-requests: read
actions: read

env:
VERSION: "${{ github.ref_name }}"
BUILD_PLATFORMS: "linux/amd64,linux/arm64,darwin/amd64,darwin/arm64,windows/amd64"
PARALLELIZE: "false"
GO_VERSION: "1.21.4"

defaults:
run:
shell: bash

on:
workflow_dispatch: { }
push:
tags:
- "v*.*.*"
branches:
- "main"
paths-ignore:
- "docs/**"
- "**.md"
- "**.mdx"
- "**.png"
- "**.jpg"
pull_request:
branches:
- "main"
paths-ignore:
- "docs/**"
- "**.md"
- "**.mdx"
- "**.png"
- "**.jpg"

jobs:
build:
timeout-minutes: 60
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# checkout the whole histories for commitsar,
# currently commitsar needs full git objects to work correctly.
fetch-depth: 0
persist-credentials: false
- name: Setup Go
timeout-minutes: 15
uses: actions/setup-go@v5
with:
go-version: "${{ env.GO_VERSION }}"
cache-dependency-path: |
**/go.sum
- name: Setup Toolbox
timeout-minutes: 5
uses: actions/cache@v3
with:
# restore/save service binaries, e.g. goimports, golangci-lint, commitsar.
key: toolbox-${{ runner.os }}
path: |
${{ github.workspace }}/.sbin
- name: Build
run: make ci
env:
LINT_DIRTY: "true"
- name: Archive Publish Result
uses: actions/cache/save@v3
with:
# save package resources, e.g. go build result, downloaded UI, entrypoint script.
key: archive-${{ runner.os }}-${{ github.sha }}
path: |
${{ github.workspace }}/.dist/build
release:
if: ${{ startsWith(github.ref, 'refs/tags/') }}
needs:
- build
permissions:
contents: write
actions: read
id-token: write
timeout-minutes: 20
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
persist-credentials: false
- name: Unarchive Publish Result
timeout-minutes: 5
uses: actions/cache/restore@v3
with:
# restore package resources, e.g. go build result, downloaded UI, entrypoint script.
key: archive-${{ runner.os }}-${{ github.sha }}
path: |
${{ github.workspace }}/.dist/build
- name: Import GPG key
id: import_gpg
uses: crazy-max/ghaction-import-gpg@v5
with:
gpg_private_key: ${{ secrets.CI_GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.CI_GPG_PASSPHRASE }}
- name: Sign Checksum
run: make release
env:
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
- name: Release
uses: softprops/action-gh-release@v1
with:
token: ${{ github.token }}
fail_on_unmatched_files: true
tag_name: ${{ steps.metadata.outputs.version }}
prerelease: ${{ contains(github.ref, 'rc') }}
files: |
.dist/build/kubecia/*
82 changes: 82 additions & 0 deletions .github/workflows/clean.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: clean

permissions:
contents: write
pull-requests: read
actions: write

defaults:
run:
shell: bash

on:
schedule:
- cron: '0 */12 * * *'
workflow_dispatch: { }

jobs:
clean:
timeout-minutes: 5
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
persist-credentials: false
- name: Remove Cache
uses: actions/github-script@v7
with:
# clean up caches,
# ref to https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#force-deleting-cache-entries,
# and https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#restrictions-for-accessing-a-cache.
script: |
const owner = context.repo.owner
const repo = context.repo.repo
var deleteCaches = new Array()
// get candidate items.
const { data: cs } = await github.rest.actions.getActionsCacheList({
owner: owner,
repo: repo,
});
for (const c of cs.actions_caches) {
// clean closed pull request's caches.
if (c.ref.match(/^refs\/pull\/.*$/)) {
var prNum = c.ref.replace(/[^\d]/g, "")
const { data: pr } = await github.rest.pulls.get({
owner: owner,
repo: repo,
pull_number: prNum,
})
if (pr.state === 'closed') {
deleteCaches.push(c)
}
continue
}
// do not clean toolbox caches.
if (c.key.match(/^toolbox-.*$/)) {
continue
}
// clean push archived caches.
if (c.key.match(/^archive-.*$/)) {
deleteCaches.push(c)
continue
}
// clean stale built caches.
if (!c.key.match(/^setup-go-.*-${{ hashFiles('**/go.sum') }}$/)) {
deleteCaches.push(c)
continue
}
}
// delete
for (const c of deleteCaches) {
await github.rest.actions.deleteActionsCacheById({
owner: owner,
repo: repo,
cache_id: c.id,
})
console.log(`cleaned cache "${c.key}"`)
}
continue-on-error: true
32 changes: 32 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Files
.DS_Store
*.lock
*.test
*.out
*.swp
*.swo
*.db
*.exe
*.exe~
*.dll
*.so
*.dylib
*.log
go.work
go.work.*

# Dirs
.idea/
.vscode/
.kube/
.terraform/
.vagrant/
.bundle/
.cache/
.docker/
.entc/
.sbin/
.dist/
log/
certs/
tmp/
Loading

0 comments on commit c53bdc8

Please sign in to comment.