diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 00fd2c3..1f8ae94 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,16 +3,47 @@ on: push: branches: - 'v*' - workflow_dispatch: jobs: - publish-tauri: + create-release: + permissions: + contents: write + runs-on: ubuntu-20.04 + outputs: + release_id: ${{ steps.create-release.outputs.result }} + + steps: + - uses: actions/checkout@v3 + - name: setup node + uses: actions/setup-node@v3 + with: + node-version: 16 + - name: get version + run: echo "PACKAGE_VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV + - name: create release + id: create-release + uses: actions/github-script@v6 + with: + script: | + const { data } = await github.rest.repos.createRelease({ + owner: context.repo.owner, + repo: context.repo.repo, + tag_name: `app-v${process.env.PACKAGE_VERSION}`, + name: `Desktop App v${process.env.PACKAGE_VERSION}`, + body: 'Take a look at the assets to download and install this app.', + draft: true, + prerelease: false + }) + return data.id + + build-tauri: + needs: create-release permissions: contents: write strategy: fail-fast: false matrix: - platform: [macos-latest, windows-latest] + platform: [macos-latest, ubuntu-20.04, windows-latest] runs-on: ${{ matrix.platform }} steps: @@ -30,8 +61,26 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - tagName: ${{ github.ref_name }} # the action automatically replaces \_\_VERSION\_\_ with the app version - releaseName: 'App v__VERSION__' - releaseBody: 'See the assets to download this version and install.' - releaseDraft: true - prerelease: false \ No newline at end of file + releaseId: ${{ needs.create-release.outputs.release_id }} + + publish-release: + permissions: + contents: write + runs-on: ubuntu-20.04 + needs: [create-release, build-tauri] + + steps: + - name: publish release + id: publish-release + uses: actions/github-script@v6 + env: + release_id: ${{ needs.create-release.outputs.release_id }} + with: + script: | + github.rest.repos.updateRelease({ + owner: context.repo.owner, + repo: context.repo.repo, + release_id: process.env.release_id, + draft: false, + prerelease: false + }) \ No newline at end of file