Compare commits

..

No commits in common. "main" and "v1.0.0" have entirely different histories.
main ... v1.0.0

3 changed files with 15 additions and 41 deletions

View File

@ -1,4 +1,4 @@
name: CI name: Action Test
on: [push] on: [push]
@ -7,7 +7,11 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
name: Should extract GAV name: Should extract GAV
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Extract GAV - name: Extract GAV
id: extract id: extract
uses: ./ uses: ./
@ -15,16 +19,10 @@ jobs:
pom-location: ${{ github.workspace }}/.github/test-resources/pom.xml pom-location: ${{ github.workspace }}/.github/test-resources/pom.xml
- name: Assert extracted GAV - name: Assert extracted GAV
run: | run: |
echo ${{ steps.extract.outputs.group-id }}
echo ${{ steps.extract.outputs.artifact-id }}
echo ${{ steps.extract.outputs.version }}
echo ${{ steps.extract.outputs.name }}
wget https://raw.github.com/lehmannro/assert.sh/v1.1/assert.sh wget https://raw.github.com/lehmannro/assert.sh/v1.1/assert.sh
. assert.sh . assert.sh
assert "echo ${{ steps.extract.outputs.group-id }}" "com.codingjam" assert "echo ${{ steps.extract.outputs.group-id }}" "com.codingjam"
assert "echo ${{ steps.extract.outputs.artifact-id }}" "github-action-poc" assert "echo ${{ steps.extract.outputs.artifact-id }}" "github-action-poc"
assert "echo ${{ steps.extract.outputs.version }}" "1.0.0-SNAPSHOT" assert "echo ${{ steps.extract.outputs.version }}" "1.0.0-SNAPSHOT"
assert "echo ${{ steps.extract.outputs.name }}" "github-action-poc"
assert_end tests assert_end tests
shell: bash shell: bash

View File

@ -1,21 +1,13 @@
# Maven GAV Extractor # Maven GAV Extractor *GitHub Action*
![Maven GAV Extractor](https://github.com/andreacomo/maven-gav-extractor/actions/workflows/test.yml/badge.svg) This action extracts GAV from `pom.xml`, i.e.:
This *GitHub Action* extracts GAV from `pom.xml`, i.e.:
* `groupId` * `groupId`
* `artifactId` * `artifactId`
* `version` * `version`
* `name` (as Maven default, get the same value of `artifactId` if not specified)
Why should I need this? For example, to **name** and **tag** a Docker image built upon your artifact or **pass as parameters** to a dispatched workflow. Why should I need this? For example, to **name** and **tag** a Docker image built upon your artifact or **pass as parameters** to a dispatched workflow.
## Versioning
This project follows *Semantic Versioning* according to [GitHub Actions versioning practice](https://github.com/actions/toolkit/blob/main/docs/action-versioning.md)
>Current stable version is `v2`
## Prerequirements ## Prerequirements
This action expects you to have `maven` available in your workflow environment This action expects you to have `maven` available in your workflow environment
@ -33,7 +25,6 @@ This action expects you to have `maven` available in your workflow environment
| `group-id` | Group Id of your project | | `group-id` | Group Id of your project |
| `artifact-id` | Artifact Id of your project | | `artifact-id` | Artifact Id of your project |
| `version` | Version of your project | | `version` | Version of your project |
| `name` | Name of your project, artifact Id if not specified |
## Example usage ## Example usage
@ -47,20 +38,18 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
name: Should extract GAV name: Should extract GAV
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v2
- name: Set up JDK 11 - name: Set up JDK 11
uses: actions/setup-java@v2 uses: actions/setup-java@v1
with: with:
java-version: 11 java-version: 11
distribution: temurin
- name: Extract GAV - name: Extract GAV
id: extract id: extract
uses: andreacomo/maven-gav-extractor@v2 uses: andreacomo/maven-gav-extractor-github-action@v1
- name: Log GAV - name: Log GAV
run: | run: |
echo ${{ steps.extract.outputs.group-id }} echo ${{ steps.extract.outputs.group-id }}
echo ${{ steps.extract.outputs.artifact-id }} echo ${{ steps.extract.outputs.artifact-id }}
echo ${{ steps.extract.outputs.version }} echo ${{ steps.extract.outputs.version }}
echo ${{ steps.extract.outputs.name }}
shell: bash shell: bash
``` ```

View File

@ -18,26 +18,13 @@ outputs:
version: version:
description: Version description: Version
value: ${{ steps.evaluate.outputs.version }} value: ${{ steps.evaluate.outputs.version }}
name:
description: Name
value: ${{ steps.evaluate.outputs.name }}
runs: runs:
using: 'composite' using: 'composite'
steps: steps:
- id: evaluate - id: evaluate
name: Extract GAV name: Extract GAV
env:
EVALUATE: org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate
run: | run: |
VALUE=$(mvn -f ${{ inputs.pom-location }} $EVALUATE -Dexpression=project.groupId -q -DforceStdout) echo "::set-output name=group-id::$(mvn -f ${{ inputs.pom-location }} org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate -Dexpression=project.groupId -q -DforceStdout)"
echo "group-id=$VALUE" >> $GITHUB_OUTPUT echo "::set-output name=artifact-id::$(mvn -f ${{ inputs.pom-location }} org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate -Dexpression=project.artifactId -q -DforceStdout)"
echo "::set-output name=version::$(mvn -f ${{ inputs.pom-location }} org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate -Dexpression=project.version -q -DforceStdout)"
VALUE=$(mvn -f ${{ inputs.pom-location }} $EVALUATE -Dexpression=project.artifactId -q -DforceStdout)
echo "artifact-id=$VALUE" >> $GITHUB_OUTPUT
VALUE=$(mvn -f ${{ inputs.pom-location }} $EVALUATE -Dexpression=project.version -q -DforceStdout)
echo "version=$VALUE" >> $GITHUB_OUTPUT
VALUE=$(mvn -f ${{ inputs.pom-location }} $EVALUATE -Dexpression=project.name -q -DforceStdout)
echo "name=$VALUE" >> $GITHUB_OUTPUT
shell: bash shell: bash