Skip to content

Commit

Permalink
build(maven): Try preparationGoals and completionGoals (#27)
Browse files Browse the repository at this point in the history
Signed-off-by: tison <wander4096@gmail.com>
  • Loading branch information
tisonkun authored Jan 6, 2023
1 parent fc75457 commit 1125c2f
Show file tree
Hide file tree
Showing 8 changed files with 195 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,6 @@ build/

### Mac OS ###
.DS_Store

### Build ###
action.yml.bak
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ inputs:

runs:
using: docker
image: docker://ghcr.io/korandoru/hawkeye-native
image: docker://ghcr.io/korandoru/hawkeye-native:latest
args:
- ${{ inputs.mode }}
- --config
Expand Down
1 change: 1 addition & 0 deletions distribution/commandline/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
</parent>

<name>HawkEye :: Distribution :: Command Line Interface</name>
<description>HawkEye command-line executables</description>
<artifactId>commandline</artifactId>

<properties>
Expand Down
15 changes: 15 additions & 0 deletions distribution/native/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,20 @@
</plugins>
</build>
</profile>
<profile>
<id>release</id>
<build>
<plugins>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<skipStaging>true</skipStaging>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
2 changes: 2 additions & 0 deletions distribution/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@
</parent>

<name>HawkEye :: Distribution</name>
<description>HawkEye distributions</description>
<artifactId>distribution</artifactId>

<packaging>pom</packaging>

<modules>
<module>commandline</module>
<module>native</module>
<module>releasehelper</module>
</modules>
</project>
82 changes: 82 additions & 0 deletions distribution/releasehelper/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2023 Korandoru Contributors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<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>
<parent>
<groupId>io.korandoru.hawkeye</groupId>
<artifactId>distribution</artifactId>
<version>1.0.3-SNAPSHOT</version>
</parent>

<name>HawkEye :: Distribution :: Release Helper</name>
<artifactId>releasehelper</artifactId>

<packaging>pom</packaging>


<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<configuration>
<skip>false</skip>
</configuration>
<executions>
<execution>
<id>before-prepare-release</id>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<arguments>v${project.version}</arguments>
</configuration>
</execution>
<execution>
<id>after-prepare-release</id>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<arguments>latest</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>release</id>
<build>
<plugins>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<skipStaging>true</skipStaging>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
59 changes: 58 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
<!-- bundled maven plugins -->
<maven-assembly-plugin.version>3.3.0</maven-assembly-plugin.version>
<maven-release-plugin.version>3.0.0-M6</maven-release-plugin.version>
<maven-scm-plugin.version>2.0.0-M3</maven-scm-plugin.version>
<maven-shade-plugin.version>3.4.1</maven-shade-plugin.version>
<maven-surefire-plugin.version>3.0.0-M7</maven-surefire-plugin.version>

Expand Down Expand Up @@ -184,11 +185,21 @@
<groupId>org.codehaus.mojo</groupId>
<version>${exec-maven-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-scm-plugin</artifactId>
<version>${maven-scm-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>${maven-shade-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>${maven-release-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
Expand Down Expand Up @@ -234,15 +245,61 @@
</configuration>
</plugin>

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<configuration>
<executable>${maven.multiModuleProjectDirectory}/tools/update-action-image-url.py</executable>
<skip>true</skip>
</configuration>
<executions>
<execution>
<id>before-prepare-release</id>
</execution>
<execution>
<id>after-prepare-release</id>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-scm-plugin</artifactId>
<executions>
<execution>
<id>add-action-yml</id>
<goals>
<goal>add</goal>
</goals>
<configuration>
<basedir>${project.basedir}</basedir>
<pushChanges>false</pushChanges>
<includes>action.yml</includes>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>${maven-release-plugin.version}</version>
<configuration>
<autoVersionSubmodules>true</autoVersionSubmodules>
<useReleaseProfile>false</useReleaseProfile>
<releaseProfiles>release</releaseProfiles>
<goals>deploy</goals>
<preparationGoals>
clean
verify
exec:exec@before-prepare-release
scm:add@add-action-yml
</preparationGoals>
<completionGoals>
clean
package
exec:exec@after-prepare-release
scm:add@add-action-yml
</completionGoals>
<signTag>true</signTag>
<tagNameFormat>v@{project.version}</tagNameFormat>
<scmCommentPrefix>ci(release):</scmCommentPrefix>
Expand Down
33 changes: 33 additions & 0 deletions tools/update-action-image-url.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env python3
# Copyright 2023 Korandoru Contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


import fileinput
import re

from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser
from pathlib import Path


if __name__ == '__main__':
parser = ArgumentParser(formatter_class=ArgumentDefaultsHelpFormatter)
parser.add_argument('version', default='latest', nargs='?', help='version of hawkeye-native image')
args = parser.parse_args()

pattern = re.compile(r'docker://ghcr.io/korandoru/hawkeye-native.*')
basedir = Path(__file__).parent.parent.absolute()
with fileinput.FileInput(basedir / 'action.yml', inplace=True, backup='.bak') as content:
for line in content:
print(pattern.sub(f'docker://ghcr.io/korandoru/hawkeye-native:{args.version}', line), end='')

0 comments on commit 1125c2f

Please sign in to comment.