-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
384 additions
and
227 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,192 @@ | ||
name: "🚀 Release Nightly" | ||
|
||
# on events | ||
on: | ||
# schedule: | ||
# - cron: '0 0 * * *' # runs daily at 00:00 | ||
workflow_dispatch: | ||
# push: | ||
# branches: [main, master, release/v*] | ||
|
||
# jobs | ||
jobs: | ||
check: | ||
name: Check has new commits today | ||
permissions: | ||
contents: write | ||
runs-on: ubuntu-latest | ||
outputs: | ||
new_commit_count: ${{steps.commit_check.outputs.new_commit_count}} | ||
steps: | ||
- name: Checkout the repository | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 1 | ||
- name: Check for new commits | ||
id: commit_check | ||
run: echo "new_commit_count=$(git log --oneline --since '24 hours ago' | wc -l)" >> $GITHUB_OUTPUT | ||
|
||
build: | ||
name: Generate cross-platform builds | ||
if: ${{needs.check.outputs.new_commit_count > 0}} | ||
needs: [check] | ||
permissions: | ||
contents: write | ||
strategy: | ||
matrix: | ||
go_version: [1.21.x] | ||
runs-on: ubuntu-latest | ||
outputs: | ||
VERSION: ${{steps.vars.outputs.VERSION}} | ||
BUILDDATE: ${{steps.vars.outputs.BUILDDATE}} | ||
COMMIT: ${{steps.vars.outputs.COMMIT}} | ||
APP_NAME: ${{steps.vars.outputs.APP_NAME}} | ||
PUSH_DOCKERHUB: ${{steps.vars.outputs.PUSH_DOCKERHUB}} | ||
steps: | ||
# step 1: checkout repository code | ||
- name: Checkout the repository | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
# step 2: setup build envirement | ||
- uses: actions/setup-go@v3 | ||
with: | ||
go-version: ${{ matrix.go_version }} | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: "20" | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
# step 3: set workflow variables | ||
- id: metadata | ||
uses: ahmadnassri/action-metadata@v2 | ||
- name: Initialize workflow environments variables | ||
id: vars | ||
run: | | ||
echo "VERSION=${{ github.ref_name }}" >> $GITHUB_OUTPUT | ||
echo "BUILDDATE=$(date '+%F-%T')" >> $GITHUB_OUTPUT | ||
echo "COMMIT=$(git rev-parse --verify HEAD)" >> $GITHUB_OUTPUT | ||
echo "APP_NAME=${{ steps.metadata.outputs.repository_name }}" >> $GITHUB_OUTPUT | ||
echo "REPO=$(echo 'github.com/${{ github.repository }}')" >> $GITHUB_OUTPUT | ||
echo "BRANCH=${{ steps.metadata.outputs.repository_default_branch }}" >> $GITHUB_OUTPUT | ||
if [ ! -z $DOCKER_TOKEN ]; then echo "PUSH_DOCKERHUB=1" >> $GITHUB_OUTPUT; fi | ||
env: | ||
DOCKER_TOKEN: "${{ secrets.DOCKER_TOKEN }}" | ||
|
||
# step 4: generate build files | ||
- name: build frontend | ||
run: cd ./web/static && npm install && npm run build | ||
- name: Generate build files | ||
uses: crazy-max/ghaction-xgo@v2 | ||
env: | ||
CGO_ENABLED: "0" | ||
with: | ||
xgo_version: latest | ||
go_version: ${{ matrix.go_version }} | ||
dest: build | ||
prefix: ${{steps.vars.outputs.APP_NAME}} | ||
targets: windows/386,windows/amd64,linux/386,linux/amd64,darwin/386,darwin/amd64,linux/386,linux/arm64 | ||
v: true | ||
x: false | ||
ldflags: -w -s -X ${{steps.vars.outputs.REPO}}/internal/app/build.Version=${{steps.vars.outputs.VERSION}} -X ${{steps.vars.outputs.REPO}}/internal/app/build.BuildDate=${{steps.vars.outputs.BUILDDATE}} -X ${{steps.vars.outputs.REPO}}/internal/app/build.Commit=${{steps.vars.outputs.COMMIT}} -X ${{steps.vars.outputs.REPO}}/internal/app/build.Mode=production | ||
|
||
# step 5: Upload binary to artifact | ||
- name: Upload artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: ${{steps.vars.outputs.APP_NAME}} | ||
path: build | ||
retention-days: 1 | ||
|
||
dockerhub: | ||
name: Push to DockerHub | ||
if: ${{needs.build.outputs.PUSH_DOCKERHUB}} | ||
needs: [build] | ||
permissions: | ||
contents: read | ||
packages: write | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout the repository | ||
uses: actions/checkout@v4 | ||
- name: Download artifact | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: ${{needs.build.outputs.APP_NAME}} | ||
path: build | ||
- name: Login to DockerHub | ||
if: ${{ steps.vars.outputs.HAS_DOCKER_TOKEN }} | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_TOKEN }} | ||
- name: Extract metadata (tags, labels) for Docker | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPOSITORY }} | ||
- name: Build and push Docker images to DockerHub | ||
if: ${{ steps.vars.outputs.HAS_DOCKER_TOKEN }} | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
push: true | ||
provenance: false | ||
platforms: linux/amd64,linux/arm64 | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
build-args: | | ||
APP_NAME=${{needs.build.outputs.APP_NAME}} | ||
VERSION=${{needs.build.outputs.VERSION}} | ||
BUILDDATE=${{needs.build.outputs.BUILDDATE}} | ||
COMMIT=${{needs.build.outputs.COMMIT}} | ||
ghcr: | ||
name: Push to GitHub Container Registry | ||
needs: [build] | ||
permissions: | ||
contents: read | ||
packages: write | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout the repository | ||
uses: actions/checkout@v4 | ||
- name: Download artifact | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: ${{needs.build.outputs.APP_NAME}} | ||
path: build | ||
- name: Display structure of downloaded files | ||
run: ls -R | ||
working-directory: build | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Extract metadata (tags, labels) for Docker | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ghcr.io/${{ github.repository }} | ||
- name: Build and push Docker images to ghci | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
push: true | ||
provenance: false | ||
platforms: linux/amd64,linux/arm64 | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
build-args: | | ||
APP_NAME=${{needs.build.outputs.APP_NAME}} | ||
VERSION=${{needs.build.outputs.VERSION}} | ||
BUILDDATE=${{needs.build.outputs.BUILDDATE}} | ||
COMMIT=${{needs.build.outputs.COMMIT}} | ||
Oops, something went wrong.