Skip to content

Nightly Build

Nightly Build #26

Workflow file for this run

name: Nightly Build
on:
schedule:
- cron: "0 10 * * *"
workflow_dispatch:
permissions:
contents: write
# packages: write
# issues: write
jobs:
check_need_build:
runs-on: ubuntu-latest
outputs:
skip: ${{ steps.check.outputs.skip }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Check Need Build
id: check
run: |
if [[ "$(git log --since='24 hours ago' | wc -l)" -eq 0 ]] || \
[[ "$GITHUB_REPOSITORY" != "Redish101/reblog" ]]; then
echo "skip=true" >> $GITHUB_OUTPUT
else
echo "skip=false" >> $GITHUB_OUTPUT
fi
test:
runs-on: ubuntu-latest
needs: check_need_build
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 1.22
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Setup PNPM
uses: pnpm/action-setup@v4
with:
version: 8.11.0
- name: Install Dependencies
run: make install-dev
- name: Build
run: make
- name: Test
run: make test
build:
needs: [check_need_build, test]
if: ${{ needs.check_need_build.outputs.skip != 'true' }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
arch: [amd64, arm64]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Cache Turbo Build Setup
uses: actions/cache@v4
with:
path: .turbo
key: ${{ runner.os }}-turbo-
restore-keys: |
${{ runner.os }}-turbo-
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 1.22
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Setup PNPM
uses: pnpm/action-setup@v4
with:
version: 8.11.0
- name: Install Dependencies
run: make install-dev
- name: Set GOARCH for AMD64
if: matrix.arch == 'amd64'
run: echo "GOARCH=amd64" >> $GITHUB_ENV
- name: Set GOARCH for ARM64
if: matrix.arch == 'arm64'
run: echo "GOARCH=arm64" >> $GITHUB_ENV
- name: Build
run: make VERSION=nightly
- name: Rename Binary
run: |
mv bin/reblog bin/reblog-${{ matrix.os }}-${{ matrix.arch }}
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os }}-${{ matrix.arch }}
path: bin/reblog-${{ matrix.os }}-${{ matrix.arch }}
release:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
path: /tmp/artifacts/
- name: Generate Changelog
run: |
git log --since='24 hours ago' --pretty=format:'* %s (%an)' > /tmp/changelog.md
echo -e "\n> [!NOTE]\n" \
"> Nightly Build不保证稳定性" >> /tmp/changelog.md
- name: Create tag and push
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
gh release delete nightly --yes || true
git push origin :refs/tags/nightly || true
git tag -f nightly
git push -f origin nightly
- name: Get Files
run: |
cd /tmp/artifacts
FILES=$(find ${DIST_DIR} -type f -exec readlink -f {} \;)
echo -e "RELEASE_FILES<<EOF" >> $GITHUB_ENV
echo -e "$FILES" >> $GITHUB_ENV
echo -e "EOF" >> $GITHUB_ENV
- name: Release
uses: softprops/action-gh-release@v2
with:
prerelease: true
tag_name: nightly
name: Nightly Build
body_path: /tmp/changelog.md
files: ${{ env.RELEASE_FILES }}
draft: false