diff --git a/.github/workflows/deploy_pages.yml b/.github/workflows/deploy_pages.yml deleted file mode 100644 index 54e3bfc8..00000000 --- a/.github/workflows/deploy_pages.yml +++ /dev/null @@ -1,42 +0,0 @@ -# Simple workflow for deploying static content to GitHub Pages -name: Deploy static content to Pages - -on: - # Runs on pushes targeting the default branch - push: - branches: ["master"] - - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: - -# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages -permissions: - contents: read - pages: write - id-token: write - -# Allow one concurrent deployment -concurrency: - group: "pages" - cancel-in-progress: true - -jobs: - # Single deploy job since we're just deploying - deploy: - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} - runs-on: ubuntu-latest - 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: - # Upload entire repository - path: './pages/dist' - - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@v1 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000..58993048 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,95 @@ +name: Release and Deploy + +on: + push: + branches: + - main + +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 + run: | + if [ -z "${{ env.LATEST_TAG }}" ]; then + echo "RELEASE_TAG=v0.1.0" >> $GITHUB_ENV + else + echo "RELEASE_TAG=${{ env.LATEST_TAG }}" >> $GITHUB_ENV + fi + + - name: Create or update GitHub release + run: | + gh auth setup-git + if gh release view "$RELEASE_TAG" &>/dev/null; then + gh release edit "$RELEASE_TAG" --generate-notes + else + 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 + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Setup Pages + uses: actions/configure-pages@v2 + + - name: Ensure dist exists + run: | + if [ ! -d "./pages/dist" ]; then + echo "Error: ./pages/dist does not exist" + exit 1 + fi + + - 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