Skip to content

Commit

Permalink
feat: add publish action
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcWadai committed Feb 4, 2025
1 parent b2f03b0 commit afd9bdb
Show file tree
Hide file tree
Showing 2 changed files with 108 additions and 103 deletions.
209 changes: 107 additions & 102 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,102 +1,107 @@
# name: "publish"

# on: pull_request

# # `tauri-action` can also upload app bundles to an existing GitHub release.
# # This workflow uses different actions to create and publish the release.
# # `tauri-action` will only build and upload the app bundles to the specified release.

# jobs:
# create-release:
# permissions:
# contents: write
# runs-on: ubuntu-latest
# outputs:
# release_id: ${{ steps.create-release.outputs.result }}

# steps:
# - uses: actions/checkout@v4

# - name: setup node
# uses: actions/setup-node@v4
# with:
# node-version: lts/*

# - 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:
# include:
# - platform: "windows-latest"
# args: ""

# runs-on: ${{ matrix.platform }}
# steps:
# - uses: actions/checkout@v4

# - name: setup node
# uses: actions/setup-node@v4
# with:
# node-version: lts/*

# - name: install Rust stable
# uses: dtolnay/rust-toolchain@stable
# with:
# # Those targets are only used on macos runners so it's in an `if` to slightly speed up windows and linux builds.
# targets: ${{ matrix.platform == 'macos-latest' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }}

# - name: install frontend dependencies
# run: |
# npm install
# npm run fetch-packages

# - uses: tauri-apps/tauri-action@v0
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# releaseId: ${{ needs.create-release.outputs.release_id }}
# args: ${{ matrix.args }}

# publish-release:
# permissions:
# contents: write
# runs-on: ubuntu-latest
# 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
# })
name: "publish"

# on:
# push:
# tags:
# - "tchap-*"

on: [pull_request]

# `tauri-action` can also upload app bundles to an existing GitHub release.
# This workflow uses different actions to create and publish the release.
# `tauri-action` will only build and upload the app bundles to the specified release.

jobs:
create-release:
permissions:
contents: write
runs-on: ubuntu-latest
outputs:
release_id: ${{ steps.create-release.outputs.result }}

steps:
- uses: actions/checkout@v4

- name: setup node
uses: actions/setup-node@v4
with:
node-version: lts/*

- 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:
include:
- platform: "windows-latest"
args: ""

runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v4

- name: setup node
uses: actions/setup-node@v4
with:
node-version: lts/*

- name: install Rust stable
uses: dtolnay/rust-toolchain@stable
with:
# Those targets are only used on macos runners so it's in an `if` to slightly speed up windows and linux builds.
targets: ${{ matrix.platform == 'macos-latest' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }}

- name: install frontend dependencies
run: |
npm install
npm run fetch-packages
- uses: tauri-apps/tauri-action@v0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
releaseId: ${{ needs.create-release.outputs.release_id }}
args: ${{ matrix.args }}

publish-release:
permissions:
contents: write
runs-on: ubuntu-latest
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
})
2 changes: 1 addition & 1 deletion .github/workflows/test_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- name: install frontend dependencies
run: |
npm install
npm run fetch-packages
npm run fetch-package
# If tagName and releaseId are omitted tauri-action will only build the app and won't try to upload any assets.
- uses: tauri-apps/tauri-action@v0
Expand Down

0 comments on commit afd9bdb

Please sign in to comment.