Create main.yml
This commit is contained in:
95
.github/workflows/main.yml
vendored
Normal file
95
.github/workflows/main.yml
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
name: Release and Deploy
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main # Adjust if your default branch is master
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
pages: write
|
||||
id-token: write
|
||||
|
||||
concurrency:
|
||||
group: "release-deploy"
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y zip gh
|
||||
|
||||
- name: Create dist zip
|
||||
run: |
|
||||
mkdir -p release
|
||||
zip -r release/dist.zip dist
|
||||
|
||||
- name: Get latest release tag
|
||||
id: get_latest_tag
|
||||
run: |
|
||||
LATEST_TAG=$(gh release list --limit 1 --json tagName -q '.[0].tagName' || echo "")
|
||||
echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_ENV
|
||||
|
||||
- name: Determine release tag
|
||||
id: tag
|
||||
run: |
|
||||
if [ -z "${{ env.LATEST_TAG }}" ]; then
|
||||
TAG="v0.1.0"
|
||||
else
|
||||
TAG="${{ env.LATEST_TAG }}"
|
||||
fi
|
||||
echo "RELEASE_TAG=$TAG" >> $GITHUB_ENV
|
||||
|
||||
- name: Create or update GitHub release
|
||||
run: |
|
||||
if gh release view "$RELEASE_TAG" &>/dev/null; then
|
||||
echo "Release exists, updating notes..."
|
||||
gh release edit "$RELEASE_TAG" --generate-notes
|
||||
else
|
||||
echo "Creating new release..."
|
||||
gh release create "$RELEASE_TAG" --generate-notes
|
||||
fi
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Upload hoc.kip
|
||||
run: |
|
||||
gh release upload "$RELEASE_TAG" dist/atmosphere/hoc.kip --clobber
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Upload dist.zip
|
||||
run: |
|
||||
gh release upload "$RELEASE_TAG" release/dist.zip --clobber
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
needs: release
|
||||
environment:
|
||||
name: github-pages
|
||||
url: ${{ steps.deployment.outputs.page_url }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Setup Pages
|
||||
uses: actions/configure-pages@v2
|
||||
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-pages-artifact@v1
|
||||
with:
|
||||
path: './pages/dist'
|
||||
|
||||
- name: Deploy to GitHub Pages
|
||||
id: deployment
|
||||
uses: actions/deploy-pages@v1
|
||||
Reference in New Issue
Block a user