Skip to content

Commit

Permalink
Try auto-release after deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
tonsky committed Sep 24, 2021
1 parent 27e212b commit 70c2fcc
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 78 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/build-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,6 @@ jobs:
python3 ./script/deploy.py --ref ${{ github.ref }}
env:
GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }}
# if: startsWith(${{ github.ref }}, 'refs/tags/')

OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
if: startsWith(${{ github.ref }}, 'refs/tags/')
19 changes: 5 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,11 @@ Electron:

## Dependency

Repository URL:

```
https://packages.jetbrains.team/maven/p/jwm/maven
```

Artifacts:

Platform | groupId | artifactId | version
------------|---------------------|-------------------|----------
macOS Intel | `org.jetbrains.jwm` | `jwm-macos-x64` | ![version](https://img.shields.io/badge/dynamic/xml?style=flat-square&label=latest&color=success&url=https%3A%2F%2Fpackages.jetbrains.team%2Fmaven%2Fp%2Fjwm%2Fmaven%2Forg%2Fjetbrains%2Fjwm%2Fjwm-macos-x64%2Fmaven-metadata.xml&query=//release)
macOS M1 | `org.jetbrains.jwm` | `jwm-macos-arm64` | ![version](https://img.shields.io/badge/dynamic/xml?style=flat-square&label=latest&color=success&url=https%3A%2F%2Fpackages.jetbrains.team%2Fmaven%2Fp%2Fjwm%2Fmaven%2Forg%2Fjetbrains%2Fjwm%2Fjwm-macos-arm64%2Fmaven-metadata.xml&query=//release)
Linux | `org.jetbrains.jwm` | `jwm-linux-x64` | ![version](https://img.shields.io/badge/dynamic/xml?style=flat-square&label=latest&color=success&url=https%3A%2F%2Fpackages.jetbrains.team%2Fmaven%2Fp%2Fjwm%2Fmaven%2Forg%2Fjetbrains%2Fjwm%2Fjwm-linux-x64%2Fmaven-metadata.xml&query=//release)
Windows | `org.jetbrains.jwm` | `jwm-windows-x64` | ![version](https://img.shields.io/badge/dynamic/xml?style=flat-square&label=latest&color=success&url=https%3A%2F%2Fpackages.jetbrains.team%2Fmaven%2Fp%2Fjwm%2Fmaven%2Forg%2Fjetbrains%2Fjwm%2Fjwm-windows-x64%2Fmaven-metadata.xml&query=//release)
Key | Value
-----------|-----------------------
groupId | io.github.humbleui.jwm
artifactId | jwm
version | ![version](https://img.shields.io/maven-central/v/io.github.humbleui.jwm/jwm)</version>

## Getting started

Expand Down
6 changes: 3 additions & 3 deletions deploy/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>space-maven</id>
<username>${space.username}</username>
<password>${space.password}</password>
<id>ossrh</id>
<username>${ossrh.username}</username>
<password>${ossrh.password}</password>
</server>
</servers>
</settings>
25 changes: 8 additions & 17 deletions docs/Getting Started.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,19 @@

First, add the latest version of JWM specific to your platform to the dependencies:

Repository URL:

```
https://packages.jetbrains.team/maven/p/jwm/maven
```

Artifacts:

Platform | groupId | artifactId | version
------------|---------------------|-------------------|----------
macOS Intel | `org.jetbrains.jwm` | `jwm-macos-x64` | ![version](https://img.shields.io/badge/dynamic/xml?style=flat-square&label=latest&color=success&url=https%3A%2F%2Fpackages.jetbrains.team%2Fmaven%2Fp%2Fjwm%2Fmaven%2Forg%2Fjetbrains%2Fjwm%2Fjwm-macos-x64%2Fmaven-metadata.xml&query=//release)
macOS M1 | `org.jetbrains.jwm` | `jwm-macos-arm64` | ![version](https://img.shields.io/badge/dynamic/xml?style=flat-square&label=latest&color=success&url=https%3A%2F%2Fpackages.jetbrains.team%2Fmaven%2Fp%2Fjwm%2Fmaven%2Forg%2Fjetbrains%2Fjwm%2Fjwm-macos-arm64%2Fmaven-metadata.xml&query=//release)
Linux | `org.jetbrains.jwm` | `jwm-linux-x64` | ![version](https://img.shields.io/badge/dynamic/xml?style=flat-square&label=latest&color=success&url=https%3A%2F%2Fpackages.jetbrains.team%2Fmaven%2Fp%2Fjwm%2Fmaven%2Forg%2Fjetbrains%2Fjwm%2Fjwm-linux-x64%2Fmaven-metadata.xml&query=//release)
Windows | `org.jetbrains.jwm` | `jwm-windows-x64` | ![version](https://img.shields.io/badge/dynamic/xml?style=flat-square&label=latest&color=success&url=https%3A%2F%2Fpackages.jetbrains.team%2Fmaven%2Fp%2Fjwm%2Fmaven%2Forg%2Fjetbrains%2Fjwm%2Fjwm-windows-x64%2Fmaven-metadata.xml&query=//release)
Key | Value
-----------|-----------------------
groupId | io.github.humbleui.jwm
artifactId | jwm
version | ![version](https://img.shields.io/maven-central/v/io.github.humbleui.jwm/jwm)</version>

E.g. for Maven it’ll look like this:

```xml
<dependency>
<groupId>org.jetbrains.jwm</groupId>
<artifactId>jwm-macos-arm64</artifactId>
<version>0.1.274</version>
<groupId>io.github.humbleui.jwm</groupId>
<artifactId>jwm</artifactId>
<version>0.2.4</version>
</dependency>
```

Expand Down
2 changes: 0 additions & 2 deletions script/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
arch = args.arch
system = {'Darwin': 'macos', 'Linux': 'linux', 'Windows': 'windows'}[platform.system()]
classpath_separator = ';' if system == 'windows' else ':'
mvn = "mvn.cmd" if system == "windows" else "mvn"
space_skija = 'https://packages.jetbrains.team/maven/p/skija/maven'
space_jwm = 'https://packages.jetbrains.team/maven/p/jwm/maven'

def fetch(url, file):
if not os.path.exists(file):
Expand Down
120 changes: 82 additions & 38 deletions script/deploy.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,46 +1,90 @@
#! /usr/bin/env python3
import argparse, build, clean, common, glob, os, platform, re, subprocess, sys
import argparse, base64, build, clean, common, glob, json, os, platform, re, subprocess, sys, time, urllib

def main():
os.chdir(os.path.dirname(__file__) + '/..')
parser = argparse.ArgumentParser()
parser.add_argument('--ref', required=True)
(args, _) = parser.parse_known_args()
rev = re.fullmatch("refs/[^/]+/([^/]+)", args.ref).group(1)

for path in glob.glob("target/*.jar") + ["target/maven/META-INF/maven/io.github.humbleui.jwm/jwm/pom.xml"]:
subprocess.check_call(["gpg",
"--armor",
"--detach-sign",
"--batch",
"--yes",
path
])

# print('Deploying jwm-shared-' + rev + ".jar")
# subprocess.check_call([
# common.mvn,
# '--batch-mode',
# '--settings', 'deploy/settings.xml',
# '-Dspace.username=Nikita.Prokopov',
# '-Dspace.password=' + os.getenv('SPACE_TOKEN'),
# 'deploy:deploy-file',
# "-Dfile=target/jwm-shared-" + rev + ".jar",
# "-DpomFile=deploy/META-INF/maven/io.github.humbleui.jwm/jwm-shared/pom.xml",
# "-DrepositoryId=space-maven",
# "-Durl=" + common.space_jwm,
# ])

# print('Deploying jwm-shared-' + rev + "-sources.jar")
# subprocess.check_call([
# common.mvn,
# '--batch-mode',
# '--settings', 'deploy/settings.xml',
# '-Dspace.username=Nikita.Prokopov',
# '-Dspace.password=' + os.getenv('SPACE_TOKEN'),
# 'deploy:deploy-file',
# "-Dpackaging=java-source",
# "-Dfile=target/jwm-shared-" + rev + "-sources.jar",
# "-DpomFile=deploy/META-INF/maven/io.github.humbleui.jwm/jwm-shared/pom.xml",
# "-DrepositoryId=space-maven",
# "-Durl=" + common.space_jwm,
# ])
ossrh_username = os.getenv('OSSRH_USERNAME')
ossrh_password = os.getenv('OSSRH_PASSWORD')

mvn = "mvn.cmd" if common.system == "windows" else "mvn"
mvn_settings = [
'--settings', 'deploy/settings.xml',
'-Dossrh.username=' + ossrh_username,
'-Dossrh.password=' + ossrh_password,
'-Durl=https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/',
'-DrepositoryId=ossrh',
'-DpomFile=target/maven/META-INF/maven/io.github.humbleui.jwm/jwm/pom.xml'
]

print('Deploying jwm-' + rev + ".jar")
subprocess.check_call(
[mvn, 'gpg:sign-and-deploy-file'] + \
mvn_settings + \
['-Dfile=target/jwm-' + rev + '.jar'])

print('Deploying jwm-' + rev + "-sources.jar")
subprocess.check_call(
[mvn, 'gpg:sign-and-deploy-file'] + \
mvn_settings + \
['-Dfile=target/jwm-' + rev + '-sources.jar',
'-Dclassifier=sources'])

print('Deploying jwm-' + rev + "-javadoc.jar")
subprocess.check_call(
[mvn, 'gpg:sign-and-deploy-file'] + \
mvn_settings + \
['-Dfile=target/jwm-' + rev + '-javadoc.jar',
'-Dclassifier=javadoc'])

headers = {
'Accept': 'application/json',
'Authorization': 'Basic ' + base64.b64encode((ossrh_username + ":" + ossrh_password).encode('utf-8')).decode('utf-8'),
'Content-Type': 'application/json',
}

def fetch(path, data = None):
req = urllib.request.Request('https://s01.oss.sonatype.org/service/local/staging' + path,
headers=headers,
data = json.dumps(data).encode('utf-8') if data else None)
resp = urllib.request.urlopen(req).read().decode('utf-8')
# print(' ', path, "->", resp)
return json.loads(resp) if resp else None

print('Finding staging repo')
resp = fetch('/profile_repositories')
repo_id = resp['data'][0]["repositoryId"]

print('Closing repo', repo_id)
resp = fetch('/bulk/close', data = {"data": {"description": "", "stagedRepositoryIds": [repo_id]}})

while True:
print('Checking repo', repo_id, 'status')
resp = fetch('/repository/' + repo_id + '/activity')
close_events = [e for e in resp if e['name'] == 'close']
close_events = close_events[0]['events'] if close_events else []
fail_events = [e for e in close_events if e['name'] == 'ruleFailed']
if fail_events:
print(fail_events)
return 1

if close_events and close_events[-1]['name'] == 'repositoryClosed':
break

time.sleep(0.5)

print('Releasing staging repo', repo_id)
resp = fetch('/bulk/promote', data = {"data": {
"autoDropAfterRelease": True,
"description": "",
"stagedRepositoryIds":[repo_id]
}})

return 0

if __name__ == "__main__":
sys.exit(main())
3 changes: 1 addition & 2 deletions script/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ def main():
compile_classpath = common.deps()
if args.jwm_version:
compile_classpath += [
common.fetch_maven('org.jetbrains.jwm', 'jwm-shared', args.jwm_version, repo=common.space_jwm),
common.fetch_maven('org.jetbrains.jwm', 'jwm-' + common.system + '-' + common.arch, args.jwm_version, repo=common.space_jwm),
common.fetch_maven('io.humbleui.jwm', 'jwm', args.jwm_version)
]
else:
compile_classpath += [
Expand Down

0 comments on commit 70c2fcc

Please sign in to comment.