Skip to content

Commit

Permalink
updating ci-cd.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
ronnnnnnnnnnnnn committed Aug 25, 2024
1 parent 47f5baf commit 752f788
Showing 1 changed file with 29 additions and 6 deletions.
35 changes: 29 additions & 6 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
if: github.event_name == 'release' && github.event.action == 'published'
permissions:
id-token: write
contents: read
contents: write
steps:
- uses: actions/checkout@v4
- name: Set up Python
Expand All @@ -47,6 +47,13 @@ jobs:
python-version: '3.12'
- name: Clean up dist folder
run: rm -rf dist/
- name: Extract version from pyproject.toml
id: extract_version
run: |
python -m pip install --upgrade pip
pip install toml
VERSION=$(python -c "import toml; print(toml.load('pyproject.toml')['project']['version'])")
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand All @@ -66,9 +73,25 @@ jobs:
pip install etekcity_esf551_ble==$VERSION
python -c "from etekcity_esf551_ble import EtekcitySmartFitnessScale, WeightUnit; print(EtekcitySmartFitnessScale, WeightUnit)"
- name: Upload Release Assets
uses: actions/upload-release-asset@v3
uses: actions/github-script@v6
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./dist/*
asset_name: ${{ github.ref_name }}-package
asset_content_type: application/zip
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const fs = require('fs').promises;
const path = require('path');
const files = await fs.readdir('dist');
for (const file of files) {
const filePath = path.join('dist', file);
const stats = await fs.stat(filePath);
if (stats.isFile()) {
console.log(`Uploading ${file}...`);
await github.rest.repos.uploadReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: context.payload.release.id,
name: file,
data: await fs.readFile(filePath)
});
}
}

0 comments on commit 752f788

Please sign in to comment.