Skip to content

Commit

Permalink
[#8] gh actions to release (#9)
Browse files Browse the repository at this point in the history
* feat: simple upload and download

* chore: upload artifact name slash to dash

* chore: split files by dir

* chore: fix path

* chore: set wd & build plugin

* chore: set phase

* chore: release action

* chore: fix

* chore: set wd to acquire version

* chore: fix

* chore: ready to merge
  • Loading branch information
cjlee38 authored Sep 22, 2024
1 parent 5d1aefa commit 5e463d6
Show file tree
Hide file tree
Showing 6 changed files with 133 additions and 59 deletions.
115 changes: 115 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
name: Release

on:
push:
tags:
- "v*.*.*"
pull_request:
branches: [ "master" ]

env:
PROJECT_NAME: gitnote
CARGO_TERM_COLOR: always

jobs:
buildCargo:
runs-on: ${{ matrix.runner }}

strategy:
fail-fast: false
matrix:
include:
- name: linux-amd64
runner: ubuntu-latest
target: x86_64-unknown-linux-gnu
libName: libgitnote.so
- name: win-amd64
runner: windows-latest
target: x86_64-pc-windows-msvc
libName: gitnote.dll
- name: macos-amd64
runner: macos-latest
target: x86_64-apple-darwin
libName: libgitnote.dylib
- name: macos-arm64
runner: macos-latest
target: aarch64-apple-darwin
libName: libgitnote.dylib
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}

- name: Build Binary
working-directory: ./gitnote-core
run: cargo build --lib --verbose --locked --release --target ${{ matrix.target }}

- name: Run tests
working-directory: ./gitnote-core
run: cargo test --lib --verbose

- name: Upload
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.target }}
path: ./gitnote-core/target/${{ matrix.target }}/release/${{ matrix.libName }}
buildJar:
runs-on: ubuntu-latest
needs: buildCargo

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Download Artifacts
uses: actions/download-artifact@v4
with:
path: ./gitnote-jetbrains/src/main/resources/core

- name: Build JAR
working-directory: ./gitnote-jetbrains
run: ./gradlew buildPlugin -Dgitnote.phase=2

- name: Get Project Version
id: get_version
working-directory: ./gitnote-jetbrains
run: echo "GITNOTE_VERSION=$(./gradlew properties -q | awk '/^version:/ {print $2}')" >> $GITHUB_ENV

- name: Upload
uses: actions/upload-artifact@v4
with:
name: gitnote-jetbrains-${{ env.GITNOTE_VERSION }}.zip
path: ./gitnote-jetbrains/build/distributions/gitnote-jetbrains-${{ env.GITNOTE_VERSION }}.zip
release:
permissions:
contents: write
runs-on: ubuntu-latest
needs: [ buildCargo, buildJar ]
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Get Project Version
id: get_version
working-directory: ./gitnote-jetbrains
run: echo "GITNOTE_VERSION=$(./gradlew properties -q | awk '/^version:/ {print $2}')" >> $GITHUB_ENV

- name: Download Artifacts
uses: actions/download-artifact@v4
with:
name: gitnote-jetbrains-${{ env.GITNOTE_VERSION }}.zip

- name: list resources
run: ls -l .

- name: Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: gitnote-jetbrains/build/distributions/gitnote-jetbrains-${{ env.GITNOTE_VERSION }}.zip

48 changes: 0 additions & 48 deletions .github/workflows/rust.yml

This file was deleted.

17 changes: 12 additions & 5 deletions gitnote-jetbrains/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ plugins {
}

group = "io.cjlee"
version = "0.1.0"
version = "0.2.0"

repositories {
mavenCentral()
Expand All @@ -29,7 +29,14 @@ intellij {
plugins.set(listOf(/* Plugin Dependencies */))
}

val development = false
// phase
// 0 : develop
// 1 : alpha
// 2 : release
val PHASE_DEVELOP = 0
val PHASE_ALPHA = 1
val PHASE_RELEASE = 2
val phase = (System.getProperty("gitnote.phase") ?: "0").toInt()

tasks {
// Set the JVM compatibility versions
Expand All @@ -48,11 +55,11 @@ tasks {

runIde {
autoReloadPlugins = true
systemProperty("gitnote.developmentPhase", development)
systemProperty("gitnote.phase", phase)
}

buildPlugin {
if (!development) {
if (phase == PHASE_ALPHA) {
dependsOn("buildCore")
dependsOn("buildGui")
}
Expand Down Expand Up @@ -94,7 +101,7 @@ tasks {
}

processResources {
if (!development) {
if (phase == PHASE_ALPHA) {
dependsOn(named("copyCore"))
dependsOn(named("copyGui"))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class JniCoreConnector(
val libFile: File by lazy {
val platform = ConnectorLoader.platform ?: throw IllegalStateException("platform is not supported")
val libName = when (platform) {
Platform.WINDOWS -> "libgitnote.dll"
Platform.WINDOWS -> "gitnote.dll"
Platform.LINUX -> "libgitnote.so"
Platform.INTEL_MAC -> "libgitnote.dylib"
Platform.SILICON_MAC -> "libgitnote.dylib"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class ProcessCoreConnector(
}

companion object {
private val isDevelopment = System.getProperty("gitnote.developmentPhase", "false").toBoolean()
private val phase = System.getProperty("gitnote.phase", "1").toInt()
private val systemCommand = arrayOf("git", "note")
val COMMAND: Array<String>

Expand All @@ -54,7 +54,7 @@ class ProcessCoreConnector(

private fun determineCommand(): Array<String> {
val platform = ConnectorLoader.platform
if (isDevelopment || platform == null) {
if (phase == 0 || platform == null) {
return systemCommand
}
val filename = when (platform) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ class GitNoteViewerWindow(
private val project: Project,
private val protocolHandlers: Map<String, ProtocolHandler>
) {
private val isDevelopment = System.getProperty("gitnote.developmentPhase", "false").toBoolean()
private val phase = System.getProperty("gitnote.phase", "1").toInt()

val webView: JBCefBrowser = JBCefBrowser.createBuilder()
.setOffScreenRendering(false)
.build()
.apply {
if (isDevelopment) this.loadURL("http://localhost:3000/index.html")
if (phase == 0) this.loadURL("http://localhost:3000/index.html")
else this.loadURL("http://gitnote/index.html")

registerAppSchemeHandler()
Expand All @@ -49,7 +49,7 @@ class GitNoteViewerWindow(
frontHandler.addHandler("theme", ThemeProtocolHandler())
jsQuery.addHandler(frontHandler)

if (isDevelopment) {
if (phase == 0) {
browser.jbCefClient.addDisplayHandler(JCefDebugDisplayHandler(), browser.cefBrowser) // for debugging
}
}
Expand Down

0 comments on commit 5e463d6

Please sign in to comment.