Skip to content

Commit f287355

Browse files
committed
feat: init
0 parents  commit f287355

19 files changed

+11075
-0
lines changed

.github/dependabot.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: github-actions
4+
directory: /
5+
schedule:
6+
interval: daily
7+
- package-ecosystem: gomod
8+
directory: /
9+
schedule:
10+
interval: daily
11+
- package-ecosystem: npm
12+
directory: /
13+
schedule:
14+
interval: daily
15+
- package-ecosystem: docker
16+
directory: /
17+
schedule:
18+
interval: daily

.github/workflows/ci-pull-request.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: ci-pull-request
2+
3+
on:
4+
pull_request:
5+
branches: [ main ]
6+
7+
defaults:
8+
run:
9+
shell: bash
10+
11+
jobs:
12+
build:
13+
name: build
14+
runs-on: ubuntu-latest
15+
steps:
16+
- id: checkout
17+
name: checkout
18+
uses: actions/checkout@v3
19+
- id: setup-go
20+
name: setup-go
21+
uses: actions/setup-go@v3
22+
with:
23+
go-version: 1.19
24+
- id: go-build
25+
name: go-build
26+
run: |
27+
OSS=(linux darwin)
28+
ARCHS=(amd64 arm64)
29+
go get
30+
for OS in "${OSS[@]}"; do
31+
for ARCH in "${ARCHS[@]}"; do
32+
env GOOS="${OS}" GOARCH="${ARCH}" \
33+
go build -o "./dist/ghapp_${OS}_${ARCH}"
34+
done
35+
done
36+
- id: docker-build
37+
name: docker-build
38+
run: |
39+
docker buildx build . \
40+
--platform=linux/amd64,linux/arm64

.github/workflows/ci.yml

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: ci
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
release:
7+
types: [ published ]
8+
9+
defaults:
10+
run:
11+
shell: bash
12+
13+
jobs:
14+
version:
15+
name: version
16+
runs-on: ubuntu-latest
17+
outputs:
18+
version: ${{ steps.emit.outputs.version }}
19+
steps:
20+
- id: checkout
21+
name: checkout
22+
uses: actions/checkout@v3
23+
- id: emit
24+
name: emit
25+
run: |
26+
echo "emitting version..."
27+
[[ ${GITHUB_REF_TYPE} == "branch" ]] && {
28+
LATEST=$(cat .version)
29+
SHA=$(git rev-parse --short "${GITHUB_SHA}")
30+
VERSION="${LATEST}-next-${SHA}"
31+
}
32+
[[ ${GITHUB_REF_TYPE} == "tag" ]] && {
33+
VERSION="${GITHUB_REF_NAME}"
34+
}
35+
echo "emitted version ${VERSION}"
36+
echo "::set-output name=version::${VERSION}"
37+
build:
38+
name: build
39+
runs-on: ubuntu-latest
40+
needs: [ version ]
41+
env:
42+
DOCKER_REGISTRY_HOST: docker.io
43+
DOCKER_REGISTRY_PATH: jhagestedt/ghapp
44+
DOCKER_REGISTRY_USERNAME: ${{ secrets.DOCKER_REGISTRY_USERNAME }}
45+
DOCKER_REGISTRY_PASSWORD: ${{ secrets.DOCKER_REGISTRY_PASSWORD }}
46+
VERSION: ${{ needs.version.outputs.version }}
47+
steps:
48+
- id: checkout
49+
name: checkout
50+
uses: actions/checkout@v3
51+
- id: setup-go
52+
name: setup-go
53+
uses: actions/setup-go@v3
54+
with:
55+
go-version: 1.19
56+
- id: go-build
57+
name: go-build
58+
run: |
59+
OSS=(linux darwin)
60+
ARCHS=(amd64 arm64)
61+
go get
62+
for OS in "${OSS[@]}"; do
63+
for ARCH in "${ARCHS[@]}"; do
64+
env GOOS="${OS}" GOARCH="${ARCH}" \
65+
go build \
66+
-o "./dist/ghapp_${OS}_${ARCH}" \
67+
-ldflags "-X main.version=${VERSION}"
68+
done
69+
done
70+
- id: go-assets
71+
name: go-assets
72+
if: ${{ github.ref_type == 'tag' }}
73+
run: |
74+
for ASSET in ./dist/*; do
75+
gh release upload "${VERSION}" "${ASSET}"
76+
done
77+
- id: docker-login
78+
name: docker-login
79+
run: |
80+
echo "${DOCKER_REGISTRY_PASSWORD}" | \
81+
docker login "${DOCKER_REGISTRY_HOST}" \
82+
--username "${DOCKER_REGISTRY_USERNAME}" \
83+
--password-stdin
84+
- id: docker-build
85+
name: docker-build
86+
run: |
87+
docker buildx build . \
88+
--push \
89+
--tag "${DOCKER_REGISTRY_HOST}/${DOCKER_REGISTRY_PATH}:${VERSION}"
90+
- id: docker-build-latest
91+
name: docker-build-latest
92+
if: ${{ github.ref_type == 'tag' }}
93+
run: |
94+
docker buildx build . \
95+
--push \
96+
--tag "${DOCKER_REGISTRY_HOST}/${DOCKER_REGISTRY_PATH}:latest"

.github/workflows/release.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: release
2+
3+
on:
4+
workflow_dispatch:
5+
branches: [ main ]
6+
7+
defaults:
8+
run:
9+
shell: bash
10+
11+
env:
12+
GIT_AUTHOR_NAME: ${{ github.actor }}
13+
GIT_AUTHOR_EMAIL: ${{ github.actor }}@users.noreply.github.com
14+
GIT_COMMITTER_NAME: ${{ github.actor }}
15+
GIT_COMMITTER_EMAIL: ${{ github.actor }}@users.noreply.github.com
16+
17+
jobs:
18+
release:
19+
name: release
20+
runs-on: ubuntu-latest
21+
steps:
22+
- id: checkout
23+
name: checkout
24+
uses: actions/checkout@v3
25+
with:
26+
fetch-depth: 0
27+
- id: setup-node
28+
name: setup-node
29+
uses: actions/setup-node@v3
30+
with:
31+
node-version: 16
32+
- id: release
33+
name: release
34+
env:
35+
GITHUB_TOKEN: ${{ secrets.PAT }}
36+
run: |
37+
npm install
38+
npm run release

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.idea/
2+
dist/
3+
node_modules/
4+
.github-app-private-key.pem

.releaserc.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
tagFormat: ${version}
2+
branches:
3+
- main
4+
plugins:
5+
- "@semantic-release/commit-analyzer"
6+
- "@semantic-release/release-notes-generator"
7+
- "@semantic-release/github"
8+
- - "@semantic-release/changelog"
9+
- changelogFile: CHANGELOG.md
10+
- - "@semantic-release/exec"
11+
- prepareCmd: >
12+
echo "${nextRelease.version}" > .version
13+
- - "@semantic-release/git"
14+
- message: "ci(release): ${nextRelease.version}"
15+
assets:
16+
- .version
17+
- CHANGELOG.md

.version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.0.1

CHANGELOG.md

Whitespace-only changes.

Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM scratch AS cli
2+
ARG TARGETOS="linux"
3+
ARG TARGETARCH="amd64"
4+
COPY ./dist/ghapp_${TARGETOS}_${TARGETARCH} /ghapp
5+
ENTRYPOINT ["/ghapp"]
6+
CMD ["help"]

0 commit comments

Comments
 (0)