Update main.yml
This commit is contained in:
100
.github/workflows/main.yml
vendored
100
.github/workflows/main.yml
vendored
@@ -4,16 +4,13 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- '**'
|
- '**'
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: write
|
||||||
pages: write
|
pages: write
|
||||||
id-token: write
|
id-token: write
|
||||||
|
|
||||||
concurrency:
|
|
||||||
group: "release-deploy"
|
|
||||||
cancel-in-progress: true
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
release:
|
release:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@@ -22,74 +19,63 @@ jobs:
|
|||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: sudo apt-get update && sudo apt-get install -y zip jq
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y zip gh
|
|
||||||
|
|
||||||
- name: Create dist zip
|
- name: Create dist zip
|
||||||
run: |
|
run: |
|
||||||
mkdir -p release
|
mkdir -p release
|
||||||
zip -r release/dist.zip dist
|
zip -r release/dist.zip dist
|
||||||
|
|
||||||
- name: Get latest release tag
|
- name: Determine latest release tag
|
||||||
id: get_latest_tag
|
id: get_latest
|
||||||
run: |
|
run: |
|
||||||
LATEST_TAG=$(gh release list --limit 1 --json tagName -q '.[0].tagName' || echo "")
|
LATEST=$(curl -s -H "Authorization: token ${{ secrets.PAT_TOKEN }}" \
|
||||||
echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_ENV
|
https://api.github.com/repos/${GITHUB_REPOSITORY}/releases/latest \
|
||||||
|
| jq -r '.tag_name // empty')
|
||||||
- name: Determine release tag
|
echo "LATEST_TAG=$LATEST" >> $GITHUB_ENV
|
||||||
run: |
|
if [ -z "$LATEST" ]; then
|
||||||
if [ -z "${{ env.LATEST_TAG }}" ]; then
|
|
||||||
echo "RELEASE_TAG=v0.1.0" >> $GITHUB_ENV
|
echo "RELEASE_TAG=v0.1.0" >> $GITHUB_ENV
|
||||||
else
|
else
|
||||||
echo "RELEASE_TAG=${{ env.LATEST_TAG }}" >> $GITHUB_ENV
|
echo "RELEASE_TAG=$LATEST" >> $GITHUB_ENV
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Create or update GitHub release
|
- name: Create or update release
|
||||||
|
id: release
|
||||||
run: |
|
run: |
|
||||||
gh auth setup-git
|
RELEASE_NAME=${{ env.RELEASE_TAG }}
|
||||||
if gh release view "$RELEASE_TAG" &>/dev/null; then
|
# Check if release exists
|
||||||
gh release edit "$RELEASE_TAG" --generate-notes
|
RELEASE_ID=$(curl -s -H "Authorization: token ${{ secrets.PAT_TOKEN }}" \
|
||||||
|
https://api.github.com/repos/${GITHUB_REPOSITORY}/releases/tags/${{ env.RELEASE_TAG }} \
|
||||||
|
| jq -r '.id // empty')
|
||||||
|
|
||||||
|
if [ -z "$RELEASE_ID" ]; then
|
||||||
|
echo "Creating release $RELEASE_NAME"
|
||||||
|
RELEASE_ID=$(curl -s -X POST -H "Authorization: token ${{ secrets.PAT_TOKEN }}" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d "{\"tag_name\":\"${{ env.RELEASE_TAG }}\",\"name\":\"$RELEASE_NAME\",\"draft\":false,\"prerelease\":false}" \
|
||||||
|
https://api.github.com/repos/${GITHUB_REPOSITORY}/releases | jq -r '.id')
|
||||||
else
|
else
|
||||||
gh release create "$RELEASE_TAG" --generate-notes
|
echo "Release exists, using ID $RELEASE_ID"
|
||||||
fi
|
fi
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
echo "RELEASE_ID=$RELEASE_ID" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Upload hoc.kip
|
- name: Upload hoc.kip
|
||||||
run: gh release upload "$RELEASE_TAG" dist/atmosphere/hoc.kip --clobber
|
run: |
|
||||||
env:
|
ASSET="dist/atmosphere/hoc.kip"
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
FILENAME=$(basename $ASSET)
|
||||||
|
curl -s -X POST \
|
||||||
|
-H "Authorization: token ${{ secrets.PAT_TOKEN }}" \
|
||||||
|
-H "Content-Type: application/octet-stream" \
|
||||||
|
--data-binary @"$ASSET" \
|
||||||
|
"https://uploads.github.com/repos/${GITHUB_REPOSITORY}/releases/${{ env.RELEASE_ID }}/assets?name=$FILENAME"
|
||||||
|
|
||||||
- name: Upload dist.zip
|
- 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: |
|
run: |
|
||||||
if [ ! -d "./pages/dist" ]; then
|
ASSET="release/dist.zip"
|
||||||
echo "Error: ./pages/dist does not exist"
|
FILENAME=$(basename $ASSET)
|
||||||
exit 1
|
curl -s -X POST \
|
||||||
fi
|
-H "Authorization: token ${{ secrets.PAT_TOKEN }}" \
|
||||||
|
-H "Content-Type: application/zip" \
|
||||||
- name: Upload artifact
|
--data-binary @"$ASSET" \
|
||||||
uses: actions/upload-pages-artifact@v1
|
"https://uploads.github.com/repos/${GITHUB_REPOSITORY}/releases/${{ env.RELEASE_ID }}/assets?name=$FILENAME"
|
||||||
with:
|
|
||||||
path: './pages/dist'
|
|
||||||
|
|
||||||
- name: Deploy to GitHub Pages
|
|
||||||
id: deployment
|
|
||||||
uses: actions/deploy-pages@v1
|
|
||||||
|
|||||||
Reference in New Issue
Block a user