Skip to content

Commit

Permalink
chore(ci/nightly): improve nightly build workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
qwqcode committed Mar 15, 2024
1 parent 1ee3c41 commit 45d56e6
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 56 deletions.
2 changes: 2 additions & 0 deletions .circleci/config.yml
Expand Up @@ -23,3 +23,5 @@ workflows:
branches:
ignore:
- gh-pages
- /release\/.+/
- nightly
88 changes: 36 additions & 52 deletions .github/workflows/build-nightly.yml
Expand Up @@ -80,14 +80,14 @@ jobs:
run: |
make build-frontend
# https://github.com/docker/build-push-action
- name: Build Multi-Platform Docker Images and Push
- name: Build `linux/amd64` and Load locally
uses: docker/build-push-action@v5
with:
push: ${{ !inputs.dry_run }}
load: true # automatically load the single-platform build result to `docker images`
push: false
context: .
file: ./Dockerfile
platforms: ${{ env.PLATFORMS }}
platforms: 'linux/amd64'
build-args: ${{ env.DOCKER_BUILD_ARGS }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
Expand All @@ -99,19 +99,19 @@ jobs:
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache

- name: Build `linux/amd64` and Load locally
# https://github.com/docker/build-push-action
- name: Build Multi-Platform Docker Images and Push
uses: docker/build-push-action@v5
if: ${{ !inputs.dry_run }}
with:
load: true # automatically load the single-platform build result to `docker images`
push: false
push: true
context: .
file: ./Dockerfile
platforms: 'linux/amd64'
platforms: ${{ env.PLATFORMS }}
build-args: ${{ env.DOCKER_BUILD_ARGS }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=local,src=/tmp/.buildx-cache
# cache-to: type=local,dest=/tmp/.buildx-cache-new

# Export docker image
- name: Export Docker Image
Expand All @@ -121,29 +121,6 @@ jobs:
docker save -o $FILENAME ${{ env.DOCKER_IMG }}
echo "filename=$FILENAME" >> $GITHUB_OUTPUT
- name: Upload Docker Image
uses: actions/upload-artifact@v4
with:
name: "${{ steps.docker_image.outputs.filename }}"
path: "${{ steps.docker_image.outputs.filename }}"

# Generate CHANGELOG
- name: Generate Changelog
run: |
# install git-chglog
curl -sL $(curl -s https://api.github.com/repos/git-chglog/git-chglog/releases/latest \
| grep -oP '"https://.+linux_amd64.tar.gz"' | tr -d \") | tar -C /usr/local/bin -xz git-chglog
changelog=$(git-chglog --config .github/chglog/config.yml --next-tag nightly nightly)
echo -e "${changelog}\n" | cat - CHANGELOG.md > temp && mv temp CHANGELOG.md
- name: Upload Changelog
uses: actions/upload-artifact@v4
with:
name: CHANGELOG.md
path: CHANGELOG.md
compression-level: 0

# Frontend
- name: Pack frontend
id: pack_frontend
Expand All @@ -153,13 +130,6 @@ jobs:
mv $PKG_FILE $FILENAME
echo "filename=$FILENAME" >> $GITHUB_OUTPUT
- name: Upload frontend
uses: actions/upload-artifact@v4
with:
name: "${{ steps.pack_frontend.outputs.filename }}"
path: "${{ steps.pack_frontend.outputs.filename }}"
compression-level: 0

# App
- name: Pack app
id: pack_app
Expand All @@ -179,27 +149,41 @@ jobs:
tar -czf $FILENAME $DEST
echo "filename=$FILENAME" >> $GITHUB_OUTPUT
- name: Upload App
uses: actions/upload-artifact@v4
with:
name: "${{ steps.pack_app.outputs.filename }}"
path: "${{ steps.pack_app.outputs.filename }}"
compression-level: 0
# Generate CHANGELOG
- name: Generate Changelog
run: |
# install git-chglog
curl -sL $(curl -s https://api.github.com/repos/git-chglog/git-chglog/releases/latest \
| grep -oP '"https://.+linux_amd64.tar.gz"' | tr -d \") | tar -C /usr/local/bin -xz git-chglog
CHANGELOG=$(git-chglog --config .github/chglog/config.yml --next-tag nightly nightly)
echo -e "$CHANGELOG" > release.md
echo -e "\n\nDocker Pull Command:\n\n\`\`\`sh\ndocker pull artalk/artalk-go:nightly\n\`\`\`" >> release.md
# checksums.txt
- name: Calculate checksums.txt
id: checksums
env:
DIST_FILES: |
DIST_FILES: |-
${{ steps.docker_image.outputs.filename }}
${{ steps.pack_app.outputs.filename }}
${{ steps.pack_frontend.outputs.filename }}
CHANGELOG.md
run: |
sha256sum $DIST_FILES > checksums.txt
- name: Upload checksums.txt
uses: actions/upload-artifact@v4
echo -e "DIST_FILES<<EOF" >> $GITHUB_ENV
echo -e "$DIST_FILES\n" >> $GITHUB_ENV
echo -e "checksums.txt" >> $GITHUB_ENV
echo -e "EOF" >> $GITHUB_ENV
echo "RELEASE_NAME=Nightly Release $(date +'%Y-%m-%d')" >> $GITHUB_ENV
- name: Release
uses: softprops/action-gh-release@v2
with:
name: checksums.txt
path: checksums.txt
compression-level: 0
draft: ${{ inputs.dry_run }}
prerelease: true
name: ${{ env.RELEASE_NAME }}
body_path: release.md
files: |
${{ env.DIST_FILES }}
checksums.txt
4 changes: 2 additions & 2 deletions .github/workflows/test-docs.yml
Expand Up @@ -2,12 +2,12 @@ name: Test Docs

on:
push:
branches: ['*', '!release/*']
branches: ['*', '!release/*', '!nightly']
paths: ['docs/**']
tags-ignore: ['v*']
pull_request:
paths: ['docs/**']
branches: ['*', '!release/*']
branches: ['*', '!release/*', '!nightly']

jobs:
test_docs:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-frontend.yml
Expand Up @@ -2,12 +2,12 @@ name: Test Frontend

on:
push:
branches: ['*', '!release/*']
branches: ['*', '!release/*', '!nightly']
paths: ['ui/**']
tags-ignore: ['v*']
pull_request:
paths: ['ui/**']
branches: ['*', '!release/*']
branches: ['*', '!release/*', '!nightly']

jobs:
test_ui:
Expand Down

0 comments on commit 45d56e6

Please sign in to comment.