-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UPDATE: build/release via Github Actions
- Loading branch information
1 parent
543493e
commit ce75196
Showing
6 changed files
with
201 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
name: build | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Set some env vars for the build | ||
run: | | ||
TIMESTAMP=$(date -u +%Y-%m-%dT%H:%M:%SZ) | ||
echo "COMMIT=${GITHUB_SHA:0:7}" >> $GITHUB_ENV | ||
echo "LASTMOD=${TIMESTAMP}" >> $GITHUB_ENV | ||
echo "BUILTBY=build.yaml" >> $GITHUB_ENV | ||
echo "IMAGE_NAME=fileformat/ghashboard" >> $GITHUB_ENV | ||
- name: Build and push | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
file: ./Dockerfile | ||
push: true | ||
tags: | | ||
ghcr.io/${{ env.IMAGE_NAME }}:latest | ||
build-args: | | ||
COMMIT=${{ env.COMMIT }} | ||
LASTMOD=${{ env.LASTMOD }} | ||
VERSION=custombuild | ||
BUILTBY=${{ env.BUILTBY }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
name: release | ||
|
||
on: | ||
push: | ||
# run only against version tags | ||
tags: | ||
- 'v*' | ||
|
||
permissions: | ||
contents: write | ||
packages: write | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Fetch all tags | ||
run: git fetch --force --tags | ||
|
||
- name: Set some env vars for the build | ||
run: | | ||
TIMESTAMP=$(date -u +%Y-%m-%dT%H:%M:%SZ) | ||
echo "COMMIT=${GITHUB_SHA:0:7}" >> $GITHUB_ENV | ||
echo "LASTMOD=${TIMESTAMP}" >> $GITHUB_ENV | ||
echo "BUILTBY=build.yaml" >> $GITHUB_ENV | ||
echo "IMAGE_NAME=fileformat/ghashboard" >> $GITHUB_ENV | ||
echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Build and push | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
file: ./Dockerfile | ||
push: true | ||
tags: | | ||
ghcr.io/${{ env.IMAGE_NAME }}:${{ env.VERSION }} | ||
ghcr.io/${{ env.IMAGE_NAME }}:latest | ||
build-args: | | ||
COMMIT=${{ env.COMMIT }} | ||
LASTMOD=${{ env.LASTMOD }} | ||
VERSION=${{ env.VERSION }} | ||
BUILTBY=${{ env.BUILTBY }} | ||
- name: Set up Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.22.1 | ||
|
||
- name: Run GoReleaser | ||
uses: goreleaser/goreleaser-action@v2 | ||
with: | ||
distribution: goreleaser | ||
version: latest | ||
args: release --clean | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Make sure to check the documentation at https://goreleaser.com | ||
before: | ||
hooks: | ||
- go mod tidy | ||
builds: | ||
- env: | ||
- CGO_ENABLED=0 | ||
ldflags: | ||
- -s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.Date}} -X main.builtBy=goreleaser | ||
main: ./ghashboard.go | ||
goos: | ||
- linux | ||
- windows | ||
- darwin | ||
|
||
archives: | ||
- format: tar.gz | ||
# this name template makes the OS and Arch compatible with the results of uname. | ||
name_template: >- | ||
{{ .ProjectName }}_ | ||
{{- title .Os }}_ | ||
{{- if eq .Arch "amd64" }}x86_64 | ||
{{- else if eq .Arch "386" }}i386 | ||
{{- else }}{{ .Arch }}{{ end }} | ||
{{- if .Arm }}v{{ .Arm }}{{ end }} | ||
# use zip for windows archives | ||
format_overrides: | ||
- goos: windows | ||
format: zip | ||
checksum: | ||
name_template: 'checksums.txt' | ||
snapshot: | ||
name_template: "{{ incpatch .Version }}-next" | ||
changelog: | ||
sort: asc | ||
filters: | ||
exclude: | ||
- '^docs:' | ||
- '^test:' | ||
|
||
# The lines beneath this are called `modelines`. See `:help modeline` | ||
# Feel free to remove those if you don't want/use them. | ||
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json | ||
# vim: set ts=2 sw=2 tw=0 fo=cnqoj |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
FROM golang:1.22-alpine AS builder | ||
|
||
RUN apk add --no-cache upx | ||
|
||
RUN mkdir /build | ||
ADD . /build/ | ||
WORKDIR /build | ||
ARG COMMIT | ||
ARG LASTMOD | ||
ARG VERSION | ||
ARG BUILTBY | ||
RUN echo "INFO: building for $COMMIT on $LASTMOD" | ||
|
||
ENV GO111MODULE=on \ | ||
CGO_ENABLED=0 \ | ||
GOOS=linux \ | ||
GOARCH=amd64 | ||
|
||
RUN go build \ | ||
-a \ | ||
-ldflags "-s -w -X main.commit=$COMMIT -X main.date=$LASTMOD -X main.version=$VERSION -X main.builtBy=$BUILTBY -extldflags '-static'" \ | ||
-o ghashboard \ | ||
./*.go \ | ||
&& upx ghashboard | ||
|
||
FROM scratch | ||
COPY --from=builder /build/ghashboard /bin/ghashboard | ||
WORKDIR /bin | ||
ENTRYPOINT ["/bin/ghashboard"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters