Skip to content

Commit

Permalink
feat: init
Browse files Browse the repository at this point in the history
  • Loading branch information
jhagestedt committed Sep 11, 2022
0 parents commit f287355
Show file tree
Hide file tree
Showing 19 changed files with 11,075 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: daily
- package-ecosystem: gomod
directory: /
schedule:
interval: daily
- package-ecosystem: npm
directory: /
schedule:
interval: daily
- package-ecosystem: docker
directory: /
schedule:
interval: daily
40 changes: 40 additions & 0 deletions .github/workflows/ci-pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: ci-pull-request

on:
pull_request:
branches: [ main ]

defaults:
run:
shell: bash

jobs:
build:
name: build
runs-on: ubuntu-latest
steps:
- id: checkout
name: checkout
uses: actions/checkout@v3
- id: setup-go
name: setup-go
uses: actions/setup-go@v3
with:
go-version: 1.19
- id: go-build
name: go-build
run: |
OSS=(linux darwin)
ARCHS=(amd64 arm64)
go get
for OS in "${OSS[@]}"; do
for ARCH in "${ARCHS[@]}"; do
env GOOS="${OS}" GOARCH="${ARCH}" \
go build -o "./dist/ghapp_${OS}_${ARCH}"
done
done
- id: docker-build
name: docker-build
run: |
docker buildx build . \
--platform=linux/amd64,linux/arm64
96 changes: 96 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: ci

on:
push:
branches: [ main ]
release:
types: [ published ]

defaults:
run:
shell: bash

jobs:
version:
name: version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.emit.outputs.version }}
steps:
- id: checkout
name: checkout
uses: actions/checkout@v3
- id: emit
name: emit
run: |
echo "emitting version..."
[[ ${GITHUB_REF_TYPE} == "branch" ]] && {
LATEST=$(cat .version)
SHA=$(git rev-parse --short "${GITHUB_SHA}")
VERSION="${LATEST}-next-${SHA}"
}
[[ ${GITHUB_REF_TYPE} == "tag" ]] && {
VERSION="${GITHUB_REF_NAME}"
}
echo "emitted version ${VERSION}"
echo "::set-output name=version::${VERSION}"
build:
name: build
runs-on: ubuntu-latest
needs: [ version ]
env:
DOCKER_REGISTRY_HOST: docker.io
DOCKER_REGISTRY_PATH: jhagestedt/ghapp
DOCKER_REGISTRY_USERNAME: ${{ secrets.DOCKER_REGISTRY_USERNAME }}
DOCKER_REGISTRY_PASSWORD: ${{ secrets.DOCKER_REGISTRY_PASSWORD }}
VERSION: ${{ needs.version.outputs.version }}
steps:
- id: checkout
name: checkout
uses: actions/checkout@v3
- id: setup-go
name: setup-go
uses: actions/setup-go@v3
with:
go-version: 1.19
- id: go-build
name: go-build
run: |
OSS=(linux darwin)
ARCHS=(amd64 arm64)
go get
for OS in "${OSS[@]}"; do
for ARCH in "${ARCHS[@]}"; do
env GOOS="${OS}" GOARCH="${ARCH}" \
go build \
-o "./dist/ghapp_${OS}_${ARCH}" \
-ldflags "-X main.version=${VERSION}"
done
done
- id: go-assets
name: go-assets
if: ${{ github.ref_type == 'tag' }}
run: |
for ASSET in ./dist/*; do
gh release upload "${VERSION}" "${ASSET}"
done
- id: docker-login
name: docker-login
run: |
echo "${DOCKER_REGISTRY_PASSWORD}" | \
docker login "${DOCKER_REGISTRY_HOST}" \
--username "${DOCKER_REGISTRY_USERNAME}" \
--password-stdin
- id: docker-build
name: docker-build
run: |
docker buildx build . \
--push \
--tag "${DOCKER_REGISTRY_HOST}/${DOCKER_REGISTRY_PATH}:${VERSION}"
- id: docker-build-latest
name: docker-build-latest
if: ${{ github.ref_type == 'tag' }}
run: |
docker buildx build . \
--push \
--tag "${DOCKER_REGISTRY_HOST}/${DOCKER_REGISTRY_PATH}:latest"
38 changes: 38 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: release

on:
workflow_dispatch:
branches: [ main ]

defaults:
run:
shell: bash

env:
GIT_AUTHOR_NAME: ${{ github.actor }}
GIT_AUTHOR_EMAIL: ${{ github.actor }}@users.noreply.github.com
GIT_COMMITTER_NAME: ${{ github.actor }}
GIT_COMMITTER_EMAIL: ${{ github.actor }}@users.noreply.github.com

jobs:
release:
name: release
runs-on: ubuntu-latest
steps:
- id: checkout
name: checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- id: setup-node
name: setup-node
uses: actions/setup-node@v3
with:
node-version: 16
- id: release
name: release
env:
GITHUB_TOKEN: ${{ secrets.PAT }}
run: |
npm install
npm run release
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.idea/
dist/
node_modules/
.github-app-private-key.pem
17 changes: 17 additions & 0 deletions .releaserc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
tagFormat: ${version}
branches:
- main
plugins:
- "@semantic-release/commit-analyzer"
- "@semantic-release/release-notes-generator"
- "@semantic-release/github"
- - "@semantic-release/changelog"
- changelogFile: CHANGELOG.md
- - "@semantic-release/exec"
- prepareCmd: >
echo "${nextRelease.version}" > .version
- - "@semantic-release/git"
- message: "ci(release): ${nextRelease.version}"
assets:
- .version
- CHANGELOG.md
1 change: 1 addition & 0 deletions .version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.0.1
Empty file added CHANGELOG.md
Empty file.
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM scratch AS cli
ARG TARGETOS="linux"
ARG TARGETARCH="amd64"
COPY ./dist/ghapp_${TARGETOS}_${TARGETARCH} /ghapp
ENTRYPOINT ["/ghapp"]
CMD ["help"]
Loading

0 comments on commit f287355

Please sign in to comment.