update workflow to delete existing release before creating new one #30
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build/release | |
| on: | |
| push: | |
| tags: | |
| - "v*" | |
| # Add permissions block | |
| permissions: | |
| contents: write | |
| jobs: | |
| release: | |
| runs-on: macos-latest | |
| strategy: | |
| matrix: | |
| arch: [x64, arm64] | |
| steps: | |
| - name: Check out Git repository | |
| uses: actions/checkout@v4 | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v3 | |
| with: | |
| version: 10.4.1 | |
| - name: Install Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: "pnpm" | |
| - name: Install dependencies | |
| run: pnpm install | |
| - name: Import certificates | |
| env: | |
| MACOS_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }} | |
| MACOS_CERTIFICATE_PWD: ${{ secrets.MACOS_CERTIFICATE_PWD }} | |
| APPLE_ID: ${{ secrets.APPLE_ID }} | |
| APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} | |
| APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }} | |
| KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }} | |
| run: | | |
| # Write certificate to file and decode it | |
| echo "$MACOS_CERTIFICATE" | base64 -D > certificate.p12 | |
| # Create keychain | |
| security create-keychain -p "$KEYCHAIN_PASSWORD" build.keychain | |
| security default-keychain -s build.keychain | |
| security unlock-keychain -p "$KEYCHAIN_PASSWORD" build.keychain | |
| # Import certificate | |
| security import certificate.p12 -k build.keychain -P "$MACOS_CERTIFICATE_PWD" -T /usr/bin/codesign | |
| security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$KEYCHAIN_PASSWORD" build.keychain | |
| # Verify certificate import | |
| security find-identity -v -p codesigning build.keychain | |
| - name: Build and sign app | |
| env: | |
| APPLE_ID: ${{ secrets.APPLE_ID }} | |
| APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} | |
| APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }} | |
| ARCH: ${{ matrix.arch }} | |
| run: pnpm run make -- --arch=${{ matrix.arch }} | |
| - name: Rename artifacts for architecture | |
| run: | | |
| cd out | |
| for f in **/*.zip; do | |
| if [ -f "$f" ]; then | |
| directory=$(dirname "$f") | |
| filename=$(basename "$f") | |
| extension="${filename##*.}" | |
| filename="${filename%.*}" | |
| mv "$f" "$directory/${filename}-${{ matrix.arch }}.${extension}" | |
| fi | |
| done | |
| # Delete existing release if it exists | |
| - name: Delete existing release | |
| uses: dev-drprasad/[email protected] | |
| with: | |
| tag_name: ${{ github.ref_name }} | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| delete_release: true | |
| # Create new release | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v1 | |
| if: startsWith(github.ref, 'refs/tags/') | |
| with: | |
| files: | | |
| out/**/*.zip | |
| draft: false | |
| prerelease: false | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |