Skip to content

Commit

Permalink
ci: testing upload build script
Browse files Browse the repository at this point in the history
  • Loading branch information
thegrannychaseroperation committed Dec 9, 2024
1 parent 09cf207 commit 2c93312
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 49 deletions.
95 changes: 48 additions & 47 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,57 +30,58 @@ jobs:
S3_SECRET_ACCESS_KEY: ${{ secrets.S3_SECRET_ACCESS_KEY }}
S3_BUILDS_BUCKET_NAME: ${{ secrets.S3_BUILDS_BUCKET_NAME }}
BUILD_WEBHOOK_URL: ${{ secrets.BUILD_WEBHOOK_URL }}
GITHUB_ACTOR: ${{ github.actor }}
run: node scripts/upload-build.cjs

- name: Install Python
uses: actions/setup-python@v5
with:
python-version: 3.9
# - name: Install Python
# uses: actions/setup-python@v5
# with:
# python-version: 3.9

- name: Install dependencies
run: pip install -r requirements.txt
# - name: Install dependencies
# run: pip install -r requirements.txt

- name: Build with cx_Freeze
run: python torrent-client/setup.py build
# - name: Build with cx_Freeze
# run: python torrent-client/setup.py build

- name: Build Linux
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y libarchive-tools
yarn build:linux
env:
MAIN_VITE_API_URL: ${{ vars.MAIN_VITE_STAGING_API_URL }}
MAIN_VITE_AUTH_URL: ${{ vars.MAIN_VITE_STAGING_AUTH_URL }}
MAIN_VITE_CHECKOUT_URL: ${{ vars.MAIN_VITE_STAGING_CHECKOUT_URL }}
MAIN_VITE_ANALYTICS_API_URL: ${{ vars.MAIN_VITE_ANALYTICS_API_URL }}
RENDERER_VITE_INTERCOM_APP_ID: ${{ vars.RENDERER_VITE_INTERCOM_APP_ID }}
RENDERER_VITE_EXTERNAL_RESOURCES_URL: ${{ vars.RENDERER_VITE_EXTERNAL_RESOURCES_URL }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# - name: Build Linux
# if: matrix.os == 'ubuntu-latest'
# run: |
# sudo apt-get update
# sudo apt-get install -y libarchive-tools
# yarn build:linux
# env:
# MAIN_VITE_API_URL: ${{ vars.MAIN_VITE_STAGING_API_URL }}
# MAIN_VITE_AUTH_URL: ${{ vars.MAIN_VITE_STAGING_AUTH_URL }}
# MAIN_VITE_CHECKOUT_URL: ${{ vars.MAIN_VITE_STAGING_CHECKOUT_URL }}
# MAIN_VITE_ANALYTICS_API_URL: ${{ vars.MAIN_VITE_ANALYTICS_API_URL }}
# RENDERER_VITE_INTERCOM_APP_ID: ${{ vars.RENDERER_VITE_INTERCOM_APP_ID }}
# RENDERER_VITE_EXTERNAL_RESOURCES_URL: ${{ vars.RENDERER_VITE_EXTERNAL_RESOURCES_URL }}
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Build Windows
if: matrix.os == 'windows-latest'
run: yarn build:win
env:
MAIN_VITE_API_URL: ${{ vars.MAIN_VITE_STAGING_API_URL }}
MAIN_VITE_AUTH_URL: ${{ vars.MAIN_VITE_STAGING_AUTH_URL }}
MAIN_VITE_CHECKOUT_URL: ${{ vars.MAIN_VITE_STAGING_CHECKOUT_URL }}
MAIN_VITE_ANALYTICS_API_URL: ${{ vars.MAIN_VITE_ANALYTICS_API_URL }}
RENDERER_VITE_INTERCOM_APP_ID: ${{ vars.RENDERER_VITE_INTERCOM_APP_ID }}
RENDERER_VITE_EXTERNAL_RESOURCES_URL: ${{ vars.RENDERER_VITE_EXTERNAL_RESOURCES_URL }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# - name: Build Windows
# if: matrix.os == 'windows-latest'
# run: yarn build:win
# env:
# MAIN_VITE_API_URL: ${{ vars.MAIN_VITE_STAGING_API_URL }}
# MAIN_VITE_AUTH_URL: ${{ vars.MAIN_VITE_STAGING_AUTH_URL }}
# MAIN_VITE_CHECKOUT_URL: ${{ vars.MAIN_VITE_STAGING_CHECKOUT_URL }}
# MAIN_VITE_ANALYTICS_API_URL: ${{ vars.MAIN_VITE_ANALYTICS_API_URL }}
# RENDERER_VITE_INTERCOM_APP_ID: ${{ vars.RENDERER_VITE_INTERCOM_APP_ID }}
# RENDERER_VITE_EXTERNAL_RESOURCES_URL: ${{ vars.RENDERER_VITE_EXTERNAL_RESOURCES_URL }}
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Create artifact
uses: actions/upload-artifact@v4
with:
name: Build-${{ matrix.os }}
path: |
dist/*-portable.exe
dist/*.zip
dist/*.dmg
dist/*.deb
dist/*.rpm
dist/*.tar.gz
dist/*.yml
dist/*.blockmap
dist/*.pacman
# - name: Create artifact
# uses: actions/upload-artifact@v4
# with:
# name: Build-${{ matrix.os }}
# path: |
# dist/*-portable.exe
# dist/*.zip
# dist/*.dmg
# dist/*.deb
# dist/*.rpm
# dist/*.tar.gz
# dist/*.yml
# dist/*.blockmap
# dist/*.pacman
10 changes: 8 additions & 2 deletions scripts/upload-build.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ const { S3Client, PutObjectCommand } = require("@aws-sdk/client-s3");
const path = require("node:path");
const packageJson = require("../package.json");

if (!process.env.BUILD_WEBHOOK_URL) {
console.log("No BUILD_WEBHOOK_URL provided, skipping upload");
process.exit(0);
}

const s3 = new S3Client({
region: "auto",
endpoint: process.env.S3_ENDPOINT,
Expand All @@ -20,7 +25,7 @@ const extensionsToUpload = [".deb", ".exe", ".png"];
fs.readdir(dist, async (err, files) => {
if (err) throw err;

const results = await Promise.all(
const uploads = await Promise.all(
files.map(async (file) => {
if (extensionsToUpload.includes(path.extname(file))) {
const fileName = `${new Date().getTime()}-${file}`;
Expand All @@ -47,9 +52,10 @@ fs.readdir(dist, async (err, files) => {
"Content-Type": "application/json",
},
body: JSON.stringify({
results,
uploads,
branchName: process.env.BRANCH_NAME,
version: packageJson.version,
actor: process.env.GITHUB_ACTOR,
}),
});
});

0 comments on commit 2c93312

Please sign in to comment.