Add post-reactions #109
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
name: Build and Release | |
on: | |
push: | |
branches: | |
- master | |
- main | |
workflow_dispatch: | |
permissions: | |
contents: write | |
jobs: | |
build-and-release: | |
name: Build and Release AngorHub | |
runs-on: ubuntu-latest | |
env: | |
PROJECT_NAME: "angor-hub" | |
steps: | |
# Step 1: Checkout repository | |
- name: Checkout Code | |
uses: actions/checkout@v3 | |
with: | |
submodules: true | |
# Step 2: Setup Node.js | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 20 | |
cache: 'npm' | |
# Step 3: Install dependencies | |
- name: Install Dependencies | |
run: npm ci | |
# Step 4: Determine version | |
- name: Set Version Variable | |
run: | | |
VERSION=$(npm run version --silent || echo "0.0.1") | |
echo "VERSION=$VERSION" >> $GITHUB_ENV | |
# Step 5: Set Release name | |
- name: Set Release Name | |
run: | | |
RELEASE_NAME=${{ env.PROJECT_NAME }}-${{ env.VERSION }}.zip | |
echo "RELEASE_NAME=$RELEASE_NAME" >> $GITHUB_ENV | |
# Step 6: Build the project | |
- name: Build Project | |
run: npm run build | |
# Step 7: Verify build output | |
- name: Verify Build Output | |
run: ls -la dist | |
continue-on-error: false | |
# Step 8: Package build output | |
- name: Package Project | |
run: | | |
cd dist | |
zip -r ../${{ env.RELEASE_NAME }} . | |
continue-on-error: false | |
# Step 9: Upload Artifact | |
- name: Upload Build Artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ env.PROJECT_NAME }}-preview-${{ env.VERSION }} | |
path: ${{ env.RELEASE_NAME }} | |
# Step 10: Create or Update GitHub Release | |
- name: Create or Update GitHub Release | |
run: | | |
if gh release view ${{ env.VERSION }}; then | |
gh release upload ${{ env.VERSION }} ${{ env.RELEASE_NAME }} --clobber | |
else | |
gh release create ${{ env.VERSION }} ${{ env.RELEASE_NAME }} --title "${{ env.PROJECT_NAME }} v${{ env.VERSION }}" --draft --notes "Auto-generated release for version ${{ env.VERSION }}" | |
fi | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |