Skip to content

Commit 22cf6a2

Browse files
committed
- [+] use GH actions for CD
1 parent 67fcd94 commit 22cf6a2

File tree

3 files changed

+189
-0
lines changed

3 files changed

+189
-0
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
#
7+
# ******** NOTE ********
8+
# We have attempted to detect the languages in your repository. Please check
9+
# the `language` matrix defined below to confirm you have the correct set of
10+
# supported CodeQL languages.
11+
#
12+
name: "CodeQL"
13+
14+
on:
15+
push:
16+
# branches: [ main ]
17+
paths-ignore:
18+
- '**/*.md'
19+
pull_request:
20+
# The branches below must be a subset of the branches above
21+
# branches: [ main ]
22+
paths-ignore:
23+
- '**/*.md'
24+
schedule:
25+
# The default branch at 14:32 UTC on the 1st of every month
26+
- cron: '32 14 1 * *'
27+
28+
jobs:
29+
analyze:
30+
name: Analyze
31+
runs-on: ubuntu-latest
32+
permissions:
33+
actions: read
34+
contents: read
35+
security-events: write
36+
37+
strategy:
38+
fail-fast: false
39+
matrix:
40+
language: [ 'go' ]
41+
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
42+
# Learn more:
43+
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
44+
45+
steps:
46+
- name: Checkout repository
47+
uses: actions/checkout@v2
48+
49+
# Initializes the CodeQL tools for scanning.
50+
- name: Initialize CodeQL
51+
uses: github/codeql-action/init@v1
52+
with:
53+
languages: ${{ matrix.language }}
54+
# If you wish to specify custom queries, you can do so here or in a config file.
55+
# By default, queries listed here will override any specified in a config file.
56+
# Prefix the list here with "+" to use these queries and those in the config file.
57+
# queries: ./path/to/local/query, your-org/your-repo/queries@main
58+
59+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
60+
# If this step fails, then you should remove it and run the build manually (see below)
61+
- name: Autobuild
62+
uses: github/codeql-action/autobuild@v1
63+
64+
# ℹ️ Command-line programs to run using the OS shell.
65+
# 📚 https://git.io/JvXDl
66+
67+
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
68+
# and modify them (or add more) to build your code if your project
69+
# uses a compiled language
70+
71+
#- run: |
72+
# make bootstrap
73+
# make release
74+
75+
- name: Perform CodeQL Analysis
76+
uses: github/codeql-action/analyze@v1
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: build
2+
3+
on:
4+
push:
5+
branches:
6+
- 'master'
7+
tags:
8+
- 'v*'
9+
10+
env:
11+
GO111MODULE: off
12+
13+
jobs:
14+
build:
15+
runs-on: ubuntu-latest
16+
steps:
17+
-
18+
name: Set up Go
19+
uses: actions/setup-go@v2
20+
with:
21+
go-version: 1.16
22+
23+
-
24+
name: Install Cloudsmith CLI
25+
run: pip install --upgrade cloudsmith-cli
26+
# Cloudsmith CLI tooling for pushing releases
27+
# See https://help.cloudsmith.io/docs/cli
28+
29+
-
30+
name: Checkout
31+
uses: actions/checkout@v2
32+
with:
33+
fetch-depth: 0
34+
35+
-
36+
name: Tests
37+
run: |
38+
export GOPATH=/home/runner/go
39+
mkdir -p $GOPATH/src/github.com/$GITHUB_ACTOR
40+
mv $GITHUB_WORKSPACE $GOPATH/src/github.com/$GITHUB_ACTOR
41+
ln -s $GOPATH/src/github.com/$GITHUB_REPOSITORY $GITHUB_WORKSPACE
42+
# go mod tidy
43+
go get -v ./...
44+
go test -v ./...
45+
46+
-
47+
name: Run GoReleaser
48+
uses: goreleaser/goreleaser-action@v2
49+
if: success() && startsWith(github.ref, 'refs/tags/')
50+
with:
51+
version: latest
52+
args: release --rm-dist
53+
env:
54+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55+
56+
# Publish to cloudsmith repo
57+
-
58+
name: Publish package to cloudsmith
59+
if: success() && startsWith(github.ref, 'refs/tags/')
60+
env:
61+
CLOUDSMITH_API_KEY: ${{ secrets.CLOUDSMITH_API_KEY }}
62+
run: |
63+
for filepath in dist/*; do
64+
echo "== Analyzing '$filepath' for publishing"
65+
filename=$(basename -- "$filepath")
66+
extension="${filename##*.}"
67+
filename="${filename%.*}"
68+
case "$extension" in
69+
'apk')
70+
echo "Pushing '$filepath' to cloudsmith repo"
71+
cloudsmith push alpine suntong/repo/alpine/any-version $filepath
72+
;;
73+
'deb' | 'rpm')
74+
echo "Pushing '$filepath' to cloudsmith repo"
75+
cloudsmith push $extension suntong/repo/any-distro/any-version $filepath
76+
;;
77+
*)
78+
echo "File .$extension skipped publishing"
79+
echo
80+
;;
81+
esac
82+
done

.goreleaser.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
project_name: emd
2+
3+
archives:
4+
- format: tar.gz
5+
wrap_in_directory: true
6+
format_overrides:
7+
- goos: windows
8+
format: zip
9+
# remove README and LICENSE
10+
files:
11+
- none*
12+
13+
builds:
14+
- env: [CGO_ENABLED=0]
15+
goos:
16+
- linux
17+
- windows
18+
- darwin
19+
goarch:
20+
- amd64
21+
- arm64
22+
23+
nfpms:
24+
- maintainer: Tong Sun <[email protected]>
25+
description: Enhanced Markdown template processor
26+
homepage: https://github.com/suntong/emd
27+
license: MIT
28+
formats:
29+
- deb
30+
- rpm
31+
- apk

0 commit comments

Comments
 (0)