-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
331 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,29 @@ | ||
# publish-tools | ||
Tools for package publishing | ||
|
||
# GPG | ||
|
||
1. Install GNU GPG | ||
|
||
```bash | ||
brew install gnupg | ||
``` | ||
|
||
2. Generate GPG keys | ||
|
||
```bash | ||
gpg --generate-key | ||
``` | ||
|
||
3. Get key id | ||
|
||
```bash | ||
gpg --list-secret-keys --keyid-format=long | ||
``` | ||
|
||
4. Export the gpg private key | ||
|
||
```bash | ||
gpg --export-secret-keys -a <key-id> > secret.txt | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
- Maven central publish https://github.com/WasiqB/maven-publish-action |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/usr/bin/env python3 | ||
|
||
from os import environ, makedirs | ||
from posixpath import dirname | ||
from tempfile import NamedTemporaryFile | ||
import init | ||
import sys | ||
from pathlib import Path | ||
from src.ansible_utils import load_vars | ||
from src.mvn_utils import publish_mvn_package | ||
from src.version_utils import get_version | ||
|
||
root_directory = Path(__file__).parent.parent | ||
secrets = load_vars(sys.argv[2], root_directory / 'vars/vault.yaml') | ||
|
||
# version= get_version( | ||
# src=root_directory, | ||
# tag_prefix="npm-package", | ||
# ) | ||
|
||
publish_mvn_package( | ||
src=root_directory / 'src', | ||
version=4, | ||
tag_prefix="npm-package", | ||
npm_access_token=secrets['npm_access_token'], | ||
github_access_token=sys.argv[1] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import xml.etree.ElementTree as xml | ||
import sys | ||
|
||
from subprocess import run | ||
from pathlib import Path | ||
from textwrap import dedent | ||
from typing import List | ||
from .github_utils import create_release | ||
|
||
def get_package_info(root_path: Path): | ||
root = xml.parse(root_path / 'pom.xml').getroot() | ||
namespace = {'maven': 'http://maven.apache.org/POM/4.0.0'} | ||
group_id = root.find('maven:groupId', namespace) | ||
artifact_id = root.find('maven:artifactId', namespace) | ||
|
||
return { | ||
'group_id': group_id.text, # type: ignore | ||
'artifact_id': artifact_id.text # type: ignore | ||
} | ||
|
||
|
||
def set_package_version(root_path: Path, version: int): | ||
tree = xml.parse(root_path / 'pom.xml') | ||
root = tree.getroot() | ||
namespace = {'maven': 'http://maven.apache.org/POM/4.0.0'} | ||
version_tag = root.find('maven:version', namespace) | ||
|
||
version_tag.text = f'{version}.0.0' # type: ignore | ||
|
||
tree.write(root_path / 'pom.xml', encoding='utf-8', xml_declaration=True) | ||
|
||
|
||
# def authenticate(src: Path, npm_access_token: str): | ||
# with open(src / '.npmrc', 'w') as file: | ||
# file.write( | ||
# f'//registry.npmjs.org/:_authToken={npm_access_token}') | ||
# file.close() | ||
# run(['npm', 'whoami'], cwd=src, check=True) | ||
|
||
|
||
def publish_mvn_package( | ||
*, | ||
src: Path, | ||
version: int, | ||
tag_prefix: str, | ||
npm_access_token: str, | ||
github_access_token: str | ||
): | ||
|
||
if not npm_access_token: | ||
print('NPM access token is missing', flush=True, file=sys.stderr) | ||
exit(1) | ||
|
||
if not github_access_token: | ||
print('GitHub access token is missing', flush=True, file=sys.stderr) | ||
exit(1) | ||
|
||
package_name = get_package_info(src) | ||
set_package_version(src, version) | ||
|
||
print(package_name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>io.github.mucsi96</groupId> | ||
<artifactId>publish-tools-test</artifactId> | ||
<version>1.0.0</version> | ||
<name>publish-tools-test</name> | ||
<url>https://github.com/mucsi96/publish-tools</url> | ||
<description>Test deploy</description> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<maven.compiler.source>21</maven.compiler.source> | ||
<maven.compiler.target>21</maven.compiler.target> | ||
</properties> | ||
|
||
<developers> | ||
<developer> | ||
<name>Igor Bari</name> | ||
</developer> | ||
</developers> | ||
|
||
<licenses> | ||
<license> | ||
<name>MIT</name> | ||
</license> | ||
</licenses> | ||
|
||
<scm> | ||
<url>[email protected]:mucsi96/publish-tools.git</url> | ||
</scm> | ||
|
||
<profiles> | ||
<!-- Deployment profile (required so these plugins are only used when deploying) --> | ||
<profile> | ||
<id>release</id> | ||
<build> | ||
<plugins> | ||
<!-- Source plugin --> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-source-plugin</artifactId> | ||
<version>3.3.1</version> | ||
<executions> | ||
<execution> | ||
<id>attach-sources</id> | ||
<goals> | ||
<goal>jar-no-fork</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
|
||
<!-- Javadoc plugin --> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-javadoc-plugin</artifactId> | ||
<version>3.7.0</version> | ||
<executions> | ||
<execution> | ||
<id>attach-javadocs</id> | ||
<goals> | ||
<goal>jar</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
<configuration> | ||
<source>17</source> | ||
</configuration> | ||
</plugin> | ||
|
||
<!-- GPG plugin --> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-gpg-plugin</artifactId> | ||
<version>3.2.4</version> | ||
<executions> | ||
<execution> | ||
<id>sign-artifacts</id> | ||
<phase>verify</phase> | ||
<goals> | ||
<goal>sign</goal> | ||
</goals> | ||
<configuration> | ||
<!-- Prevent `gpg` from using pinentry programs --> | ||
<gpgArguments> | ||
<arg>--pinentry-mode</arg> | ||
<arg>loopback</arg> | ||
</gpgArguments> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</profile> | ||
</profiles> | ||
|
||
<build> | ||
<plugins> | ||
<!-- Central Publishing Plugin --> | ||
<plugin> | ||
<groupId>org.sonatype.central</groupId> | ||
<artifactId>central-publishing-maven-plugin</artifactId> | ||
<version>0.5.0</version> | ||
<extensions>true</extensions> | ||
<configuration> | ||
<publishingServerId>central</publishingServerId> | ||
<tokenAuth>true</tokenAuth> | ||
<autoPublish>false</autoPublish> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<settings | ||
xmlns="http://maven.apache.org/SETTINGS/1.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd" | ||
> | ||
<profiles> | ||
<profile> | ||
<id>gpg</id> | ||
<activation> | ||
<activeByDefault>true</activeByDefault> | ||
</activation> | ||
<properties> | ||
<gpg.executable>gpg</gpg.executable> | ||
<gpg.passphrase>${env.GPG_PASSPHRASE}</gpg.passphrase> | ||
</properties> | ||
</profile> | ||
</profiles> | ||
<servers> | ||
<server> | ||
<id>${env.SERVER_ID}</id> | ||
<username>${env.SERVER_USERNAME}</username> | ||
<password>${env.SERVER_PASSWORD}</password> | ||
</server> | ||
</servers> | ||
</settings> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,60 @@ | ||
$ANSIBLE_VAULT;1.1;AES256 | ||
63393530323735636537323966346533383934633530646139383162346537646161313834636231 | ||
3761633634383766643065633166636635636561343634650a633138376566393131376566316563 | ||
34613737383962373766373233316263343732613231646630653930376137666466316630663237 | ||
6363646261393030350a313136376364633766393538383432613339393832613338316230373335 | ||
36393635643936663162666331363732396436643333643061313564333764663666626464323165 | ||
30306661626665346235303734376261633837313631646538363463373465663031366236633463 | ||
33313863386665623637646666656365343732343566383530353334356563613836366563396163 | ||
33343039346432393530373332333930666339656262643763313061623032663434383238653563 | ||
64633932666338393838313965646162346262653334666130376133396233633434333664363634 | ||
3630323430313830363537373333616638396464343665316661 | ||
31313866613136336332366435633361383766396235303861633863313339376365346433366565 | ||
6663393235313934653635396235393861393762653264380a353763356339376134373732636133 | ||
33666364386366636532396266663766313539613237366630313463303237336364336563356230 | ||
6534643334643439370a393635373865666566323834376666633263383331623366323430316466 | ||
37326135326438353762313234303538643462633934393366363839646336323732633331666466 | ||
32383033643336353032643431303332306365646165323731616130353564356639613031396231 | ||
65323730356538333166333030343766633562346161323133333934373866386163343334323234 | ||
32623165386130393564663665366430336135383765323034643664633737633733633236323934 | ||
31353766363665626338326435313238306365373563633961643935663062356337663962336532 | ||
34653838373262376633366133343634383164633737623733303632333566323366343831323238 | ||
62366365343665336434383633643230303138633430623336633363646533303436663162313337 | ||
61373661383065316332303238386235363830626230366636323438333538623935613565663531 | ||
36326430366636623837366135613035646336616166643839363536656336643065393261323664 | ||
65623565323465326632626239663734616464336232613439303361633562366635646639353139 | ||
39383734306332393765393634366234613437303033646366633965356663336432326532616361 | ||
30666334646534643530393365636462623536373963633166313362356565333938376130323134 | ||
31376363383031646239316633653063643032393362353237383164353735656530393764373931 | ||
38646437653830653536353637366562316234386236663262323532666366643063316130343536 | ||
66623839303637623665323866393639366665363534356461313338666462666438356564643234 | ||
34393835313131303266356332383738646531663839643236663630313633333133326530373963 | ||
35356335306439326635616434626139636263663061376266373230353462623939663039343739 | ||
38663336633763353362373965396333336566383565386366653766393339336239353731623939 | ||
31313264326633363437616463653264613430643834636565613032336264373232386364323730 | ||
64326138353835356638373835313435653364383063376463666363306630336335643134313264 | ||
35303963333138653661663837386631306161633737616132396263626438313163306536666634 | ||
31663864373631303237393165346665316233343765303432643336343262353764353839656662 | ||
30326230643930376330623330393632373762363632646535333338353239393761386338643034 | ||
35366234373565393061363833333136646632633466366665336130336130363561616231656334 | ||
63656561303735613533333537666562613838396665303861326163653262366631653463333037 | ||
61343266313636353761366436663463393536336331343831386534393865303730383932653131 | ||
34666562353538363662623636636132616434313131326432346362656431363362393563323939 | ||
65336666653661646433303562363032363537616534646465393066383861363966323735303764 | ||
33353062663161613633356236376235383232393833623162626639613337633936623961613865 | ||
33343361633065383634386165363431373733643365373038363132636664636538306437343665 | ||
61373231383734333263343832316363383831353964636239303530633661356665356133383062 | ||
38393234373764323863656138386162623633386536646262396361313331363832653363623064 | ||
64303664623234313930376233343238383966393235396165623635386464303034363632306432 | ||
66636664383633643436613237613538303362326661386435383263373830656665306238343563 | ||
30383039616364326362323965623237656535306134323666643934633936373737636431396539 | ||
66353932376561376366393332313938653337643834663762373731663462343531306365663633 | ||
63396538623338306537356661393735643265366136313864373039343638353837303034353762 | ||
63336136613535336532663263666564386333306362633431336132306335356366376637333564 | ||
64383064386334663533316566353364303463653061306466613134623130363462646539386430 | ||
64636561323731333134313164373631306565663262646663383734303636393332643362336537 | ||
34613732663966643137336431316331626634343264613364303663323234333063396366356161 | ||
37386537326464336463663136376364333831666530373335663662663438663661656261333461 | ||
30343039393437326461373237373537653836663633313033396138626562313063613464393532 | ||
34323264386238646139393464303938613832313036313066636232376335336235333439393238 | ||
65396262336131373166333864383236656239663330363764313534656135623933386666303538 | ||
31396337346466306434626364343863303762663635336665646531663363636439343561313834 | ||
31366566653538626231353931333764613363393337633130343739383966663564356365643764 | ||
36613964313636383533666661336537663666383162396563343166396432353364363361373866 | ||
36616266393739643431613163393561636532633934303038336262616433613933613263313838 | ||
66323735326564313035313933393538373134636230356139346261353339356439643133356134 | ||
66646564363864343631383866313466643162626564666362363236623939653538306537303133 | ||
35646138376632363437346434366437376331333961653166343966383966353264356363373731 | ||
62623835653531366166663862316632623962333831643730363730323363343834313931366666 | ||
63323261623430363763386537363836396630633665386134333762303437636533376330343561 | ||
623463326563333265363839666165353863 |