diff --git a/.github/workflows/openid-federation-base-workflow.yml b/.github/workflows/openid-federation-base-workflow.yml new file mode 100644 index 0000000..5f92463 --- /dev/null +++ b/.github/workflows/openid-federation-base-workflow.yml @@ -0,0 +1,34 @@ +# Copyright 2024 OIDC Sweden +# +# 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 +# +# http://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. + +name: openid-federation-base workflow + +on: + push: + branches: + - main + tags: + - "v[0-9]+.[0-9]+.[0-9]+" + pull_request: + branches: + - main +jobs: + test: + permissions: + contents: read + uses: ./.github/workflows/test.yml + publish-jar: + if: startsWith(github.ref, 'refs/tags/v') + needs: [test] + uses: ./.github/workflows/publish-to-github-packages.yml diff --git a/.github/workflows/publish-to-github-packages.yml b/.github/workflows/publish-to-github-packages.yml new file mode 100644 index 0000000..0ed1901 --- /dev/null +++ b/.github/workflows/publish-to-github-packages.yml @@ -0,0 +1,49 @@ +# Copyright 2024 OIDC Sweden +# +# 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 +# +# http://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. + +name: Publish artifact to github packages + +on: [workflow_call] + +jobs: + publish: + name: Build and Publish + runs-on: ubuntu-latest + + permissions: + contents: read + packages: write + + steps: + - name: Checkout Repository + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 + + - name: Set up Java for publishing to GitHub Packages + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + + - name: Build, Generate SBOM, and Deploy + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + mvn -B clean package cyclonedx:makeAggregateBom + mvn -B -e deploy -DskipTests -DaltDeploymentRepository=github::https://maven.pkg.github.com/oidc-sweden/openid-federation-base + + - name: Upload SBOM + uses: actions/upload-artifact@v4 + with: + name: sbom + path: target/bom.json diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..86ceb81 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,48 @@ +# Copyright 2024 OIDC Sweden +# +# 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 +# +# http://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. + +name: mvn Test + +on: [workflow_call] + +permissions: + contents: read + +jobs: + test: + name: Test + runs-on: ubuntu-latest + strategy: + matrix: + java-version: ['21'] + os: [ubuntu-latest] + + steps: + - name: Harden GitHub runner + uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2 + with: + egress-policy: audit + + - name: Checkout repository + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Set up JDK ${{ matrix.java-version }} + uses: actions/setup-java@8df1039502a15bceb9433410b1a100fbe190c53b # v4.5.0 + with: + java-version: ${{ matrix.java-version }} + distribution: 'temurin' + cache: 'maven' + + - name: Run tests + run: mvn test --batch-mode diff --git a/pom.xml b/pom.xml index 1cd208c..0200b3e 100644 --- a/pom.xml +++ b/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 se.oidc.oidfed @@ -212,6 +213,15 @@ + + org.apache.maven.plugins + maven-deploy-plugin + 3.1.1 + + false + + + org.apache.maven.plugins maven-surefire-plugin @@ -231,7 +241,7 @@ enforce - + @@ -240,6 +250,30 @@ + + + org.cyclonedx + cyclonedx-maven-plugin + 2.7.9 + + + package + + makeAggregateBom + + + + + library + 1.4 + true + true + true + true + true + false + + @@ -322,4 +356,4 @@ - + \ No newline at end of file