Skip to content

github action

github action #1

name: Build and Release
on:
push:
branches: [ master ]
workflow_dispatch:
jobs:
build-and-release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: latest
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Setup pnpm cache
uses: actions/cache@v4
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build project
run: pnpm build
- name: Verify build output
run: |
if [ ! -d "./out" ]; then
echo "Build output directory './out' not found!"
exit 1
fi
echo "Build output directory exists with $(find ./out -type f | wc -l) files"
- name: Create zip archive
run: |
cd out
zip -r ../steem-clone-build.zip . -x "*.DS_Store" "*.git*"
- name: Get version from package.json
id: version
run: |
VERSION=$(node -p "require('./package.json').version")
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "tag=v$VERSION" >> $GITHUB_OUTPUT
- name: Create Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.version.outputs.tag }}
release_name: Release ${{ steps.version.outputs.tag }}
body: |
## Steem Clone Build Release
This release contains the built static files for the Steem clone website.
### What's included:
- Static HTML files
- CSS and JavaScript assets
- Images and other static resources
### Installation:
1. Download the `steem-clone-build.zip` file
2. Extract the contents to your web server
3. Configure your web server to serve the static files
### Build Info:
- Node.js version: 20
- Build date: ${{ github.run_number }}
- Commit: ${{ github.sha }}
draft: false
prerelease: false
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./steem-clone-build.zip
asset_name: steem-clone-build.zip
asset_content_type: application/zip