Skip to content
This repository has been archived by the owner on Sep 1, 2024. It is now read-only.

Commit

Permalink
Publish every build to the Nightly channel
Browse files Browse the repository at this point in the history
  • Loading branch information
InSyncWithFoo committed Jul 28, 2024
1 parent d9d3bd5 commit a8e4120
Show file tree
Hide file tree
Showing 9 changed files with 135 additions and 41 deletions.
40 changes: 39 additions & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ jobs:
draft:
name: Release draft
if: github.event_name != 'pull_request'
needs: [ build, test, inspect, verify ]
needs: [ build, test, verify ]
runs-on: ubuntu-latest

permissions:
Expand Down Expand Up @@ -285,3 +285,41 @@ jobs:
${{ needs.build.outputs.changelog }}
EOM
)"
nightly:
name: Publish nightly version
if: github.event_name != 'pull_request'
needs: [ build, test, verify ]
runs-on: ubuntu-latest

steps:
-
name: Fetch sources
uses: actions/checkout@v4
-
name: Set up Java
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 17
-
name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.x
-
name: Set up Gradle
uses: gradle/actions/setup-gradle@v3
with:
gradle-home-cache-cleanup: true
-
name: Publish plugin to Nightly channel
env:
PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN }}
CERTIFICATE_CHAIN: ${{ secrets.CERTIFICATE_CHAIN }}
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
PRIVATE_KEY_PASSWORD: ${{ secrets.PRIVATE_KEY_PASSWORD }}
run: |
chmod +x ./gradlew
NIGHTLY_VERSION=$(python .scripts/modify_build_for_nightly.py)
./gradlew publishPlugin -Pchannel=Nightly -PpluginVersion=${NIGHTLY_VERSION}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.scripts/
!.scripts/changelog.py
!.scripts/edit_releases.py
!.scripts/modify_build_for_nightly.py

TODO.md
.credentials/
Expand Down
48 changes: 48 additions & 0 deletions .scripts/modify_build_for_nightly.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import re
import subprocess
from pathlib import Path
from typing import cast


_version = re.compile(r'^pluginVersion = (?P<version>.+)', re.M)


def get_head_commit_hash() -> str:
output = subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD'])
return output.decode('ascii').strip()


def get_nightly_version(content: str) -> str:
head_commit_hash = get_head_commit_hash()

version_line = cast(re.Match[str], _version.search(content))
current_version = version_line['version']

return f'{current_version}-{head_commit_hash}'


def modify_content(content: str) -> tuple[str, str]:
nightly_version = get_nightly_version(content)
new_content = _version.sub(
f'pluginVersion = {nightly_version}',
content
)

return nightly_version, new_content


def main():
gradle_properties = Path('gradle.properties')

with open(gradle_properties, 'r') as file:
content = file.read()

with open(gradle_properties, 'w') as file:
nightly_version, new_content = modify_content(content)
file.write(new_content)

print(nightly_version)


if __name__ == '__main__':
main()
8 changes: 7 additions & 1 deletion CHANGELOG_CODE.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ For user-facing changes, see [`CHANGELOG.md`][_-1].

## [Unreleased]

<i>This section is currently empty.</i>
### Changed

* Builds are now published to the Nightly channel. (HEAD)

### Dependencies

* IntelliJ Platform Gradle Plugin is updated to 2.0.0-rc2. (d9d3bd53)


## [0.1.0-whl1] - 2024-07-25
Expand Down
2 changes: 1 addition & 1 deletion docs/actions.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## uv: Sync

It might be helpful if you don't want to use
This action might be helpful if you don't want to use
[the corresponding intention][1] for some reasons.

!!! note
Expand Down
5 changes: 2 additions & 3 deletions docs/other-features.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
## File icons

In the [<i>Project</i> tool window][1], the icons for
`uv.lock` and `uv.toml` files are replaced
with uv logos.
In the [<i>Project</i> tool window][1] and other places,
the icons for `uv.lock` and `uv.toml` files are replaced with uv logos.


[1]: https://www.jetbrains.com/help/pycharm/project-tool-window.html
20 changes: 20 additions & 0 deletions src/main/kotlin/insyncwithfoo/uv/Messages.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package insyncwithfoo.uv

import com.intellij.openapi.project.Project
import com.intellij.openapi.ui.Messages

internal fun somethingIsWrong(title: String, message: String, project: Project? = null) {
Messages.showErrorDialog(project, message, title)
}

internal fun somethingIsWrong(message: String, project: Project? = null) {
somethingIsWrong(title = message("messages.somethingIsWrong.title"), message, project)
}

internal fun Project?.somethingIsWrong(title: String, message: String) {

Check warning on line 14 in src/main/kotlin/insyncwithfoo/uv/Messages.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unused symbol

Function "somethingIsWrong" is never used
somethingIsWrong(title, message, project = this)
}

internal fun Project?.somethingIsWrong(message: String) {

Check warning on line 18 in src/main/kotlin/insyncwithfoo/uv/Messages.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unused symbol

Function "somethingIsWrong" is never used
somethingIsWrong(message, project = this)
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,20 @@ import com.intellij.notification.NotificationGroupManager
import com.intellij.notification.NotificationType
import com.intellij.notification.NotificationsManager
import com.intellij.openapi.project.Project
import com.intellij.openapi.ui.Messages
import insyncwithfoo.uv.icons.UVIcon


private const val ID = "uv notifications"
private val ICON = UVIcon.SMALL_SIMPLIFIED


internal val uvNotificationGroup: NotificationGroup

Check warning on line 17 in src/main/kotlin/insyncwithfoo/uv/Notifications.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unused symbol

Property "uvNotificationGroup" is never used
get() {
val groupManager = NotificationGroupManager.getInstance()
return groupManager.getNotificationGroup(ID)
}


internal fun Notification.prettify() = apply {

Check warning on line 24 in src/main/kotlin/insyncwithfoo/uv/Notifications.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unused symbol

Function "prettify" is never used
isImportant = false
icon = ICON
Expand All @@ -35,34 +41,7 @@ internal fun NotificationGroup.createErrorNotification(title: String, content: S
createNotification(title, content, NotificationType.ERROR)


internal val uvNotificationGroup: NotificationGroup
get() {
val groupManager = NotificationGroupManager.getInstance()
return groupManager.getNotificationGroup(ID)
}


internal val Project.openingUVNotifications: List<Notification>

Check warning on line 44 in src/main/kotlin/insyncwithfoo/uv/Notifications.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unused symbol

Property "openingUVNotifications" is never used
get() = NotificationsManager.getNotificationsManager()
.getNotificationsOfType(Notification::class.java, this)
.filter { it.groupId == ID }


internal fun somethingIsWrong(title: String, message: String, project: Project? = null) {
Messages.showErrorDialog(project, message, title)
}


internal fun somethingIsWrong(message: String, project: Project? = null) {
somethingIsWrong(title = message("messages.somethingIsWrong.title"), message, project)
}


internal fun Project?.somethingIsWrong(title: String, message: String) {
somethingIsWrong(title, message, project = this)
}


internal fun Project?.somethingIsWrong(message: String) {
somethingIsWrong(message, project = this)
}
17 changes: 10 additions & 7 deletions src/main/kotlin/insyncwithfoo/uv/icons/UVFilesIconProvider.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,18 @@ import com.intellij.openapi.vfs.VirtualFile


/**
* Provides customized directory-tree icons
* for `uv.lock` and `uv.toml.
* Provides customized icons for `uv.lock` and `uv.toml.
*
* These icons are used in the *Project* tool window
* and editor tabs, among others.
*/
internal class UVFilesIconProvider : FileIconProvider, DumbAware {

override fun getIcon(file: VirtualFile, flags: Int, project: Project?) = when (file.name) {
"uv.lock" -> UVIcon.TINY_SIMPLIFIED_WHITE
"uv.toml" -> UVIcon.TINY_SIMPLIFIED
else -> null
}
override fun getIcon(file: VirtualFile, flags: Int, project: Project?) =
when (file.name) {
"uv.lock" -> UVIcon.TINY_SIMPLIFIED_WHITE
"uv.toml" -> UVIcon.TINY_SIMPLIFIED
else -> null
}

}

0 comments on commit a8e4120

Please sign in to comment.