Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto Tag Release #47

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 0 additions & 42 deletions .github/workflows/build_and_publish.yaml

This file was deleted.

71 changes: 71 additions & 0 deletions .github/workflows/build_on_merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Build on Merge

on:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
actions: write
repository-projects: write
packages: write

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up JDK
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'adopt'

# - name: Add execute permissions to script
# run: chmod +x ./check-version.sh
#
# - name: Check if version exists
# id: chkvrsn
# run: ./check-version.sh
# env:
# PAT: ${{ secrets.PAT }}
# USER: ${{ secrets.USER }}

- name: Build with Maven
run: mvn clean install

- name: Configure GIT
run: |
git config --global user.name 'gdTest'
git config --global user.email '[email protected]'

- name: Create tag
id: create_tag
run: |
mvn scm:tag

TAG=$(git describe --tags --abbrev=0)
echo "Tag: $TAG"
echo "::set-output name=tag::$TAG"

- name: Trigger Release Workflow
uses: peter-evans/repository-dispatch@v1
with:
token: ${{ secrets.PAT }}
event-type: trigger-release
client-payload: '{"tag_name": "${{ steps.create_tag.outputs.tag }}"}'

- name: Update pom to next version
run: mvn -U build-helper:parse-version versions:set -DnewVersion='${parsedVersion.majorVersion}.${parsedVersion.nextMinorVersion}' versions:commit

- name: Commit Changes
run: |
git add .
git commit -m "Actions Updated POM"

- name: Push Changes
if: github.ref == 'refs/heads/main'
run: git push origin main
27 changes: 27 additions & 0 deletions .github/workflows/deploy_artifact.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Deploy Package

on: workflow_dispatch

jobs:
deploy:
runs-on: ubuntu-latest
env:
CODEARTIFACT_AUTH_TOKEN: ${{ secrets.PAT }}

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up JDK
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'adopt'

- name: Build with Maven
run: mvn -B package --file pom.xml

- name: Publish to GitHub Packages
run: mvn -s ./settings.xml deploy
env:
GITHUB_TOKEN: ${{ secrets.PAT }}
24 changes: 24 additions & 0 deletions .github/workflows/release_on_tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Release on TAG

on:
repository_dispatch:
types: [trigger-release]

jobs:
create-release:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.PAT }}
with:
tag_name: ${{ github.event.client_payload.tag_name }}
release_name: Release ${{ github.event.client_payload.tag_name }}
draft: false
prerelease: false
67 changes: 48 additions & 19 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<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/maven-v4_0_0.xsd">
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.gamedoora</groupId>
Expand All @@ -18,6 +18,13 @@
<maven.wagon.http.retryHandler.count>3</maven.wagon.http.retryHandler.count>
</properties>

<scm>
<connection>scm:git:https://github.com/gamedoora/gamedoora-model.git</connection>
<developerConnection>scm:git:https://github.com/gamedoora/gamedoora-model.git</developerConnection>
<url>https://github.com/gamedoora/gamedoora-model</url>
<tag>${project.version}</tag>
</scm>

<build>
<plugins>
<plugin>
Expand Down Expand Up @@ -72,6 +79,28 @@
</configFiles>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.5.0</version>
<executions>
<execution>
<configuration>
<goals>pre-integration-test</goals>
<preparationGoals>package</preparationGoals>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-scm-plugin</artifactId>
<version>2.0.1</version>
<configuration>
<connectionUrl>scm:git:https://github.com/gamedoora/gamedoora-model.git</connectionUrl>
<tag>${project.version}</tag>
</configuration>
</plugin>
<!--<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
Expand All @@ -93,11 +122,11 @@
</build>

<dependencies>
<!-- <dependency>-->
<!-- <groupId>org.flywaydb</groupId>-->
<!-- <artifactId>flyway-core</artifactId>-->
<!-- <version>8.5.13</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.flywaydb</groupId>-->
<!-- <artifactId>flyway-core</artifactId>-->
<!-- <version>8.5.13</version>-->
<!-- </dependency>-->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand All @@ -114,11 +143,11 @@
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.flywaydb</groupId>-->
<!-- <artifactId>flyway-core</artifactId>-->
<!-- <version>8.5.13</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.flywaydb</groupId>-->
<!-- <artifactId>flyway-core</artifactId>-->
<!-- <version>8.5.13</version>-->
<!-- </dependency>-->
<!-- https://mvnrepository.com/artifact/org.postgresql/postgresql -->
<dependency>
<groupId>org.postgresql</groupId>
Expand All @@ -131,12 +160,12 @@
<version>1.5.3.Final</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.26</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.26</version>
<scope>compile</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-context -->
<dependency>
<groupId>org.springframework</groupId>
Expand All @@ -154,7 +183,7 @@
</dependencies>
<distributionManagement>
<repository>
<id>github</id>
<id>codeartifact</id>
<name>GitHub GameDoora Model's Apache Maven Packages</name>
<url>https://maven.pkg.github.com/gamedoora/gamedoora-model</url>
</repository>
Expand Down