diff --git a/.github/workflows/maven-publish.yml b/.github/workflows/maven-develop-publish.yml similarity index 52% rename from .github/workflows/maven-publish.yml rename to .github/workflows/maven-develop-publish.yml index 42dd57f..114c1ce 100644 --- a/.github/workflows/maven-publish.yml +++ b/.github/workflows/maven-develop-publish.yml @@ -1,12 +1,7 @@ -# This workflow will build a package using Maven and then publish it to GitHub packages when a release is created -# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#apache-maven-with-a-settings-path - -name: Maven Package +name: Maven Package - Trigger on: workflow_dispatch: - release: - types: [created] jobs: build: @@ -18,13 +13,15 @@ jobs: steps: - uses: actions/checkout@v4 + with: + ref: develop - name: Set up JDK 17 uses: actions/setup-java@v3 with: java-version: '17' distribution: 'temurin' - server-id: github # Value of the distributionManagement/repository/id field of the pom.xml - settings-path: ${{ github.workspace }} # location for the settings.xml file + server-id: github + settings-path: ${{ github.workspace }} - name: Build with Maven run: mvn -B package --file pom.xml diff --git a/.github/workflows/maven-release.yml b/.github/workflows/maven-release.yml new file mode 100644 index 0000000..f637d73 --- /dev/null +++ b/.github/workflows/maven-release.yml @@ -0,0 +1,51 @@ +name: Maven Package and Release + +on: + push: + branches: + - main + +jobs: + build: + + runs-on: ubuntu-latest + permissions: + contents: write + actions: write + repository-projects: write + packages: write + + steps: + - uses: actions/checkout@v4 + with: + ref: main + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + server-id: github + settings-path: ${{ github.workspace }} + + - name: Maven Release x GitHub Packages + run: | + git config --global user.name "cosad3s - Github Actions" + git config --global user.email "cosad3s@outlook.com" + mvn release:prepare --batch-mode + mvn release:perform -s $GITHUB_WORKSPACE/settings.xml + env: + GITHUB_TOKEN: ${{ github.token }} + + - name: Get the new tag + id: get_tag + run: echo "::set-output name=tag::$(git describe --tags $(git rev-list --tags --max-count=1))" + + - name: Create the release + uses: softprops/action-gh-release@v2 + with: + name: Release ${{ steps.get_tag.outputs.tag }} + tag_name: ${{ steps.get_tag.outputs.tag }} + files: | + target/salsa-jar-with-dependencies.jar + make_latest: true + token: ${{ github.token }} \ No newline at end of file