Skip to content

Commit

Permalink
CI to handle versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
querwurzel committed Nov 7, 2023
1 parent d722af5 commit 891aee8
Show file tree
Hide file tree
Showing 9 changed files with 124 additions and 96 deletions.
15 changes: 3 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,11 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
mvn deploy -DskipTests -Drevision=1.0.${{ github.run_number }} -Denv=mysql
mvn versions:set -DnewVersion=1.0.${{ github.run_number }}
mvn deploy -DskipTests -Denv=mysql
- uses: actions/delete-package-versions@v4
with:
package-name: 'com.github.binpastes.app'
package-type: 'maven'
min-versions-to-keep: 10
- uses: actions/delete-package-versions@v4
with:
package-name: 'com.github.binpastes.frontend'
package-type: 'maven'
min-versions-to-keep: 10
- uses: actions/delete-package-versions@v4
with:
package-name: 'com.github.binpastes.backend'
package-type: 'maven'
min-versions-to-keep: 10
min-versions-to-keep: 3
10 changes: 8 additions & 2 deletions backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.github.binpastes</groupId>
<artifactId>app</artifactId>
<version>${revision}</version>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand All @@ -17,7 +17,6 @@
<dependency>
<groupId>com.github.binpastes</groupId>
<artifactId>frontend</artifactId>
<version>${revision}</version>
</dependency>

<dependency>
Expand Down Expand Up @@ -102,6 +101,13 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>false</skip>
</configuration>
</plugin>
</plugins>
</build>

Expand Down
152 changes: 88 additions & 64 deletions frontend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,72 +2,96 @@
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.github.binpastes</groupId>
<artifactId>app</artifactId>
<version>${revision}</version>
<relativePath>../pom.xml</relativePath>
</parent>
<parent>
<groupId>com.github.binpastes</groupId>
<artifactId>app</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>frontend</artifactId>
<artifactId>frontend</artifactId>

<build>
<plugins>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<configuration>
<nodeVersion>v18.16.1</nodeVersion>
</configuration>
<executions>
<execution>
<id>install node and npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
</execution>
<execution>
<id>pnpm install</id>
<goals>
<goal>npx</goal>
</goals>
<configuration>
<arguments>pnpm install</arguments>
</configuration>
</execution>
<execution>
<id>pnpm build</id>
<goals>
<goal>npx</goal>
</goals>
<configuration>
<arguments>pnpm run build</arguments>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<phase>generate-resources</phase>
<goals>
<goal>resources</goal>
</goals>
<configuration>
<resources>
<resource>
<directory>dist</directory>
</resource>
</resources>
<outputDirectory>${project.build.outputDirectory}/static</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<build>
<plugins>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<configuration>
<nodeVersion>v18.18.2</nodeVersion>
</configuration>
<executions>
<execution>
<id>install node and npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
</execution>
<execution>
<id>pnpm install</id>
<goals>
<goal>npx</goal>
</goals>
<configuration>
<arguments>pnpm install</arguments>
</configuration>
</execution>
<execution>
<id>pnpm build</id>
<goals>
<goal>npx</goal>
</goals>
<configuration>
<arguments>pnpm run build</arguments>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<executions>
<execution>
<id>default-test</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<execution>
<id>default-compile</id>
<phase>none</phase>
</execution>
<execution>
<id>default-testCompile</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<phase>generate-resources</phase>
<goals>
<goal>resources</goal>
</goals>
<configuration>
<resources>
<resource>
<directory>dist</directory>
</resource>
</resources>
<outputDirectory>${project.build.outputDirectory}/static</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
13 changes: 7 additions & 6 deletions frontend/src/components/CreatePaste/CreatePaste.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const CreatePaste: Component<CreatePasteProps> = ({onCreatePaste, initialPaste})
exposure: null
});

const [lastPaste, setLastPaste] = createSignal<string>(null);
const [lastPaste, setLastPaste] = createSignal<string>();

let creationForm: HTMLFormElement

Expand All @@ -46,6 +46,7 @@ const CreatePaste: Component<CreatePasteProps> = ({onCreatePaste, initialPaste})
}

const resetStore = () => {
setLastPaste(null);
setForm({
title: null,
password: null,
Expand All @@ -56,6 +57,8 @@ const CreatePaste: Component<CreatePasteProps> = ({onCreatePaste, initialPaste})
}

const submitCreateForm = (e: Event) => {
e.preventDefault();

const data: PasteCreateCmd = {
title: form.title,
content: form.content,
Expand All @@ -70,12 +73,10 @@ const CreatePaste: Component<CreatePasteProps> = ({onCreatePaste, initialPaste})

onCreatePaste(data)
.then(url => {
setLastPaste(url);
resetCreateForm();
resetStore();
setLastPaste(url);
})

e.preventDefault();
}

return (
Expand All @@ -85,7 +86,7 @@ const CreatePaste: Component<CreatePasteProps> = ({onCreatePaste, initialPaste})
<label for="expiry">Expires in: </label>
<select id="expiry" name="expiry" onChange={updateFormField("expiry")}>
<option value="ONE_HOUR">1 Hour</option>
<option value="ONE_DAY" selected={true}>1 Day</option>
<option value="ONE_DAY" selected>1 Day</option>
<option value="ONE_WEEK">1 Week</option>
<option value="ONE_MONTH">1 Month</option>
<option value="THREE_MONTHS">3 Months</option>
Expand All @@ -97,7 +98,7 @@ const CreatePaste: Component<CreatePasteProps> = ({onCreatePaste, initialPaste})
<div>
<label>Visibility: </label>
<label for="public">
<input type="radio" id="public" name="exposure" value="PUBLIC" checked={true}
<input type="radio" id="public" name="exposure" value="PUBLIC" checked
onInput={updateFormField("exposure")}/>
Public
</label>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/ReadPaste/ReadPaste.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ interface ReadPasteProps {

const ReadPaste: Component<ReadPasteProps> = ({paste, onClonePaste, onDeletePaste}): JSX.Element => {

const [clearText, setClearText] = createSignal<string>(null);
const [clearText, setClearText] = createSignal<string>();

let keyInput: HTMLInputElement;
let content: HTMLPreElement;
Expand Down
12 changes: 6 additions & 6 deletions frontend/src/components/RecentPastes/RecentPastes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ const RecentPastes: () => JSX.Element = () => {

const appContext = AppContext;

let refreshTimer;
let refetchSchedule;

function refresh() {
function manualRefetch() {
restartSchedule();
refetch();
}

function startSchedule() {
refreshTimer = window.setInterval(refetch, 60_000);
refetchSchedule = window.setInterval(refetch, 60_000);
}

function stopSchedule() {
window.clearInterval(refreshTimer);
window.clearInterval(refetchSchedule);
}

function restartSchedule() {
Expand All @@ -51,8 +51,8 @@ const RecentPastes: () => JSX.Element = () => {
});

appContext.onPasteDeleted((paste) => {
mutate(prev => prev.filter(item => item.id !== paste.id));
restartSchedule();
mutate(prev => prev.filter(item => item.id !== paste.id));
});
})

Expand All @@ -73,7 +73,7 @@ const RecentPastes: () => JSX.Element = () => {
</Show>
</strong>
&nbsp;
<span class={styles.refresh} onClick={refresh}></span>
<span class={styles.refetch} onClick={manualRefetch}></span>
</h3>

<ol>
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/RecentPastes/recentPastes.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@
gap: 3px;
}

.refresh {
.refetch {
cursor: pointer;
color: var(--color-link);
}

.refresh:active {
.refetch:active {
filter: brightness(var(--hover-brightness));
}

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/SearchPastes/SearchPastes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {PasteListView} from '../../api/model/PasteListView';

const SearchPastes: () => JSX.Element = () => {

const [search, setSearch] = createSignal<string>(null);
const [search, setSearch] = createSignal<string>();

const [results, { refetch }] = createResource(() => search(), () => searchTerm());

Expand Down
10 changes: 8 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<groupId>com.github.binpastes</groupId>
<artifactId>app</artifactId>
<version>${revision}</version>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>BinPastes</name>

Expand All @@ -31,7 +31,6 @@
<properties>
<!-- maven property definition -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<revision>1.0.0-SNAPSHOT</revision>

<!-- java version properties -->
<maven.compiler.target>17</maven.compiler.target>
Expand Down Expand Up @@ -91,6 +90,13 @@
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>

Expand Down

0 comments on commit 891aee8

Please sign in to comment.