Skip to content

Commit

Permalink
Fix: not a git repository
Browse files Browse the repository at this point in the history
  • Loading branch information
HuangFuSL committed Mar 21, 2024
1 parent a50f16f commit 08891c8
Showing 1 changed file with 22 additions and 51 deletions.
73 changes: 22 additions & 51 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ on:

jobs:
build:
runs-on: ${{ matrix.os }}
runs-on: ${{ matrix.os }}-latest
needs: [publish]

strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
os: [ubuntu, macos, windows]

steps:
- name: Checkout code
Expand All @@ -25,33 +26,33 @@ jobs:
- name: Build application
run: cargo build --profile dist

- name: Compress artifacts (macOS & Linux)
if: matrix.os != 'windows-latest'
run: |
tar -czf target/dsp-calculator-${{ matrix.os }}.tar.gz -C target/dist dsp-calculator
- name: Compress artifacts (Windows)
if: matrix.os == 'windows-latest'
run: |
tar -czf target/dsp-calculator-${{ matrix.os }}.tar.gz -C target/dist dsp-calculator.exe
- name: Upload Release Asset (Linux & macOS)
if: matrix.os != 'windows'
run:
mv target/dist/dsp-calculator dsp-calculator-${{ matrix.os }}
gh release upload ${{ github.ref }} dsp-calculator-${{ matrix.os }} --clobber
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Archive artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os }}-release
path: target/dsp-calculator-${{ matrix.os }}.tar.gz
- name: Upload Release Asset (Windows)
if: matrix.os == 'windows'
run:
mv target/dist/dsp-calculator.exe dsp-calculator-${{ matrix.os }}.exe
gh release upload ${{ github.ref }} dsp-calculator-${{ matrix.os }}.exe --clobber
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

publish:
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Download artifacts
uses: actions/download-artifact@v2
- name: Checkout
uses: actions/checkout@v4
with:
path: release
ref: ${{ github.ref }}
fetch-depth: 1

- name: Determine if pre-release
- name: Check if pre-release
id: prerelease_check
run: |
MAJOR_VERSION=$(echo "${{ github.ref }}" | sed -E 's/^refs\/tags\/v([0-9]+)\..*$/\1/')
Expand All @@ -72,33 +73,3 @@ jobs:
${{ steps.prerelease_check.outputs.is_prerelease }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload Release Asset
id: upload-release-asset
run: |
gh release upload ${{ github.ref }} release/* --clobber
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

cleanup:
runs-on: ubuntu-latest
needs: [publish]
steps:
- name: Clean up artifacts
uses: actions/github-script@v4
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const artifacts = await github.actions.listArtifactsForRepo({
per_page: 100
});
const artifactIds = artifacts.data.artifacts
.filter(artifact => artifact.name !== 'release')
.map(artifact => artifact.id);
for (const id of artifactIds) {
await github.actions.deleteArtifact({
artifact_id: id
});
}

0 comments on commit 08891c8

Please sign in to comment.