Skip to content

Commit

Permalink
ci(build): setup to publish release
Browse files Browse the repository at this point in the history
  • Loading branch information
PalmDevs committed Sep 14, 2024
1 parent 7b707a3 commit 29e8d98
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 26 deletions.
57 changes: 33 additions & 24 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,13 @@ on:

jobs:
build:
name: Build and push
name: Build and release
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Checkout builds
uses: actions/checkout@v4
with:
repository: "pyoncord/bunny-builds"
path: "builds"
token: ${{ secrets.BUILDS_TOKEN }}
ref: ${{ github.ref_name }}

- uses: actions/setup-node@v4
with:
node-version: 20
Expand All @@ -36,18 +28,35 @@ jobs:

# TODO: Check for linting?

- name: Push builds
run: |
rm $GITHUB_WORKSPACE/builds/* || true
cp -r dist/* $GITHUB_WORKSPACE/builds || true
cd $GITHUB_WORKSPACE/builds
git config --local user.email "actions@github.com"
git config --local user.name "GitHub Actions"
git add .
git commit -m "Build $GITHUB_SHA" || exit 0
git push
- name: Purge CDN cache
run: |
curl https://purge.jsdelivr.net/gh/pyoncord/bunny-build-infos@${{ github.ref_name }}/bunny.js
- name: Get file hash
id: hash
run: echo "hash=$GITHUB_SHA" >> "$GITHUB_OUTPUT"

- name: Create draft release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.hash.outputs.hash }}
release_name: Revenge ${{ steps.hash.outputs.hash }}
draft: true
prerelease: false

- name: Upload dist
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./dist/revenge.js
asset_name: revenge.js
asset_content_type: text/javascript

- name: Publish release
uses: eregon/publish-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_id: ${{ steps.create_release.outputs.id }}

4 changes: 2 additions & 2 deletions scripts/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ let context = null;
const config = {
entryPoints: ["src/entry.ts"],
bundle: true,
outfile: "dist/bunny.js",
outfile: "dist/revenge.js",
format: "iife",
splitting: false,
external: [],
Expand All @@ -35,7 +35,7 @@ const config = {
"const-and-let": false,
},
footer: {
js: "//# sourceURL=bunny",
js: "//# sourceURL=revenge",
},
loader: {
".png": "dataurl",
Expand Down

0 comments on commit 29e8d98

Please sign in to comment.