Skip to content
This repository has been archived by the owner on Mar 4, 2022. It is now read-only.

Go Rewrite #17

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ include:
Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
advances
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
professional setting

## Our Responsibilities

Expand Down
73 changes: 73 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: CodeQL
on:
push:
branches:
- master

paths-ignore:
- '.github/**'
- '.vscode/**'
- 'assets/**'
- 'docker/**'
- '.idea/**'
- '.dockerignore'
- '.gitignore'
- '**.md'
- 'LICENSE'
- 'renovate.json'

pull_request:
branches:
- master

paths-ignore:
- '.github/**'
- '.vscode/**'
- 'assets/**'
- 'docker/**'
- '.idea/**'
- '.dockerignore'
- '.gitignore'
- '**.md'
- 'LICENSE'
- 'renovate.json'

schedule:
- cron: '21 2 * * 4'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language:
- 'go'
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Setup Go 1.17
uses: actions/setup-go@v2
with:
go-version: 1.17

- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}

- name: Install dependencies
run: |
go mod download
go get
- name: Build the project
run: make build

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
40 changes: 0 additions & 40 deletions .github/workflows/fmt.yml

This file was deleted.

106 changes: 106 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
name: Lint on Commit
on:
workflow_dispatch:
pull_request:
branches:
- 'feature/**'
- 'bug/gh-**'
- 'issue/gh-**'
- staging
- master

paths-ignore:
- '.github/**'
- '.vscode/**'
- 'assets/**'
- 'docker/**'
- '.idea/**'
- '.dockerignore'
- '.gitignore'
- '**.md'
- 'LICENSE'
- 'renovate.json'
push:
branches:
- 'feature/**'
- 'bug/gh-**'
- 'issue/gh-**'
- staging
- master

paths-ignore:
- '.github/**'
- '.vscode/**'
- 'assets/**'
- 'docker/**'
- '.idea/**'
- '.dockerignore'
- '.gitignore'
- '**.md'
- 'LICENSE'
- 'renovate.json'
permissions:
contents: read
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Setup Go 1.17
uses: actions/setup-go@v2
with:
go-version: 1.17

- name: Install dependencies
run: go mod download && go get

- name: Cache Go modules
uses: actions/cache@v2
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-${{ matrix.go-version }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-${{ matrix.go-version }}-go-

- name: Build project to see if it compiles
run: make build

- name: Format project for any formatting to apply
run: make fmt

- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
args: --issues-exit-code=1
only-new-issues: false
skip-go-installation: true
skip-pkg-cache: true
skip-build-cache: true

- name: Check if git status is dirty
id: git_status
if: ${{ github.event_name == 'push' }}
run: |
if [ -n "$(git status --porcelain)" ]; then
echo '::set-output name=DIRTY::true'
else
echo '::set-output name=DIRTY::false'
fi

- name: Commit changes (if dirty)
if: |
contains(steps.git_status.outputs.DIRTY, 'true') &&
${{ github.event_name == 'push' }}
run: |
git config --global user.name "Noel[bot]"
git config --global user.email "[email protected]"
git config --global committer.email "[email protected]"
git config --global committer.name "Noel"

git add .
git commit -m "chore: format project :sparkles:"
git push -u origin master
107 changes: 34 additions & 73 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,93 +1,54 @@
name: Release towards Docker and GitHub releases
name: Release workflow
on:
release:
types:
- published
concurrency:
group: goreleaser
cancel-in-progress: true
permissions:
contents: write
packages: write
jobs:
build-windows:
runs-on: windows-2019
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Setup Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable

- name: Build release
run: cargo build --release

- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: kanata-win_x64.exe
path: ${{ github.workspace }}/target/release/kanata.exe
retention-days: 1

build-linux:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Setup Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable

- name: Build release
run: cargo build --release
fetch-depth: 0

- name: Upload artifact
uses: actions/upload-artifact@v2
- name: Setup Go 1.17
uses: actions/setup-go@v2
with:
name: kanata-linux_x64
path: ${{ github.workspace }}/target/release/kanata
retention-days: 1
go-version: 1.17

build-macos:
runs-on: macos-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Setup Rust
uses: actions-rs/toolchain@v1
- name: Login into Docker Hub
uses: docker/login-action@v1
with:
profile: minimal
toolchain: stable

- name: Build release
run: cargo build --release
username: auguwu
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Upload artifact
uses: actions/upload-artifact@v2
- name: Login into GitHub Container Registry
uses: docker/login-action@v1
with:
name: kanata-macos_x64
path: ${{ github.workspace }}/target/release/kanata
retention-days: 1
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GH_PAT }}

publish:
runs-on: ubuntu-latest
strategy:
matrix:
runtime:
- 'win-x64.exe'
- 'linux-x64'
- 'macos-x64'
steps:
- name: Build Docker image
run: chmod +x ./scripts/build-docker.sh && ./scripts/build-docker.sh
- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Publish Docker image
run: chmod +x ./scripts/publish-docker.sh && ./scripts/publish-docker.sh
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1

- name: Add artifacts to GitHub Releases
uses: ncipollo/release-action@v1
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
allowUpdates: true
artifacts: 'kanata-${{ matrix.runtime }}'
tag: ${{ github.event.release.tag_name }}
distribution: goreleaser
version: latest
args: release --rm-dist --skip-sign
env:
HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.GH_PAT }}
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
Loading