Skip to content

Commit

Permalink
fix: updater
Browse files Browse the repository at this point in the history
  • Loading branch information
vincehi committed Jun 12, 2023
1 parent 9e56e2e commit 847b355
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 61 deletions.
134 changes: 74 additions & 60 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,72 +16,85 @@ jobs:
pull-requests: write # to be able to comment on released pull requests
id-token: write # to enable use of OIDC for npm provenance
steps:
# - uses: actions/checkout@v3
# with:
# fetch-depth: 0
# - name: Setup Node.js
# uses: actions/setup-node@v3
# - name: Install dependencies
# run: npm install @actions/core
# - name: Release
# id: get-next-release
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# run: npx semantic-release --dry-run
# outputs:
# next-release-published: ${{ steps.get-next-release.outputs.next-release-published }}
# next-release-version: ${{ steps.get-next-release.outputs.next-release-version }}
# next-release-git-tag: ${{ steps.get-next-release.outputs.next-release-git-tag }}
# next-release-notes: ${{ steps.get-next-release.outputs.next-release-notes }}
# build:
# needs: get-next-release
# if: needs.get-next-release.outputs.next-release-published == 'true'
# permissions:
# contents: write
# strategy:
# fail-fast: false
# matrix:
# platform: [ macos-latest ]
# runs-on: ${{ matrix.platform }}
# steps:
# - name: Checkout repository
# uses: actions/checkout@v3
#
# - name: Rust setup
# uses: dtolnay/rust-toolchain@stable
#
# - name: Rust cache
# uses: swatinem/rust-cache@v2
# with:
# workspaces: './src-tauri -> target'
#
# - name: Sync node version and setup cache
# uses: actions/setup-node@v3
# with:
# cache: 'npm' # Set this to npm, yarn or pnpm.
#
# - name: Install frontend dependencies
# # If you don't have `beforeBuildCommand` configured you may want to build your frontend here too.
# run: npm install # Change this to npm, yarn or pnpm.
#
# - name: Build the app
# uses: tauri-apps/tauri-action@v0
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# tagName: ${{ needs.get-next-release.outputs.next-release-git-tag }}
# releaseName: ${{ needs.get-next-release.outputs.next-release-version }}
# releaseBody: ${{ needs.get-next-release.outputs.next-release-notes }}
# releaseDraft: false
# prerelease: true
#
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v3
- name: Install dependencies
run: npm install @actions/core
- name: Release
id: get-next-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npx semantic-release --dry-run
outputs:
next-release-published: ${{ steps.get-next-release.outputs.next-release-published }}
next-release-version: ${{ steps.get-next-release.outputs.next-release-version }}
next-release-git-tag: ${{ steps.get-next-release.outputs.next-release-git-tag }}
next-release-notes: ${{ steps.get-next-release.outputs.next-release-notes }}
build:
needs: get-next-release
if: needs.get-next-release.outputs.next-release-published == 'true'
permissions:
contents: write
strategy:
fail-fast: false
matrix:
platform: [ macos-latest ]
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Rust setup
uses: dtolnay/rust-toolchain@stable

- name: Rust cache
uses: swatinem/rust-cache@v2
with:
workspaces: './src-tauri -> target'

- name: Sync node version and setup cache
uses: actions/setup-node@v3
with:
cache: 'npm' # Set this to npm, yarn or pnpm.

- name: Install frontend dependencies
# If you don't have `beforeBuildCommand` configured you may want to build your frontend here too.
run: npm install # Change this to npm, yarn or pnpm.

- name: Build the app
id: tauri-action
uses: tauri-apps/tauri-action@v0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tagName: ${{ needs.get-next-release.outputs.next-release-git-tag }}
releaseName: ${{ needs.get-next-release.outputs.next-release-version }}
releaseBody: ${{ needs.get-next-release.outputs.next-release-notes }}
releaseDraft: false
prerelease: true

- name: Checkout code
uses: actions/checkout@v3
- name: Update updater
run: |
echo "${{ fromJSON(steps.tauri-action.outputs.artifactPaths)[0] }}"
echo "${{ fromJSON(steps.tauri-action.outputs.artifactPaths)[1] }}"
echo "${{ fromJSON(steps.tauri-action.outputs.artifactPaths)[3] }}"
echo "${{ steps.tauri-action.outputs.releaseUploadUrl }}"
echo "${{ steps.tauri-action.outputs.releaseHtmlUrl }}"
echo "${{ steps.tauri-action.outputs.releaseId }}"
sig=${cat "${{ fromJSON(steps.tauri-action.outputs.artifactPaths)[2] }}")
json=$(cat ${GITHUB_WORKSPACE}/tools/pulp-updater.json)
json_var_replaced=$(echo "$json" | sed "s/\${VERSION}/${GITHUB_WORKSPACE//\//\\/}/g")
json_var_replaced=$(echo "$json" | sed \
-e "s/\${VERSION}/${{ needs.get-next-release.outputs.next-release-version }}/g" \
-e "s/\${DOWNLOAD_URL}/"https://google.com"/g" \
-e "s/\${SIGNATURE}/$sig/g" \
-e "s/\${NOTES}/${{ needs.get-next-release.outputs.next-release-notes }}/g")
json_string=$(echo $json_var_replaced | sed 's/"/\\"/g')
Expand All @@ -92,3 +105,4 @@ jobs:
-H 'Content-Type: application/json; charset=utf-8' \
-d "{\"files\":{\"pulp-updater.json\":{\"content\":\"$json_string\"}}}"
9 changes: 8 additions & 1 deletion tools/pulp-updater.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
{
"version-root": "${VERSION}"
"version": "${VERSION}",
"notes": "${NOTES}",
"platforms": {
"darwin-x86_64": {
"signature": "${SIGNATURE}",
"url": "${DOWNLOAD_URL}"
}
}
}

0 comments on commit 847b355

Please sign in to comment.