Skip to content

Commit

Permalink
Merge branch 'main' into contribute-frequency-and-angle-qks
Browse files Browse the repository at this point in the history
  • Loading branch information
fkleedorfer committed Dec 6, 2024
2 parents 673887f + 90306a8 commit db07f46
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 8 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Format sources and commit to branch
on:
workflow_dispatch:

jobs:
build:
# setting the environment on the job is mandatory, otherwise it cannot access environment secrets.
runs-on: ubuntu-latest

steps:
- name: Check write access to repo
run: |
token_login=$(curl -H "Authorization: Bearer ${token}" https://api.github.com/user | jq -r '.login')
echo token login is ${token_login}
echo $(curl -H "Authorization: Bearer ${token}" https://api.github.com/repos/${repo}/collaborators/${token_login}/permission) > result
cat result | jq '.permission == "admin" // .permission == "write"' > /dev/null || ( echo "Token does not have write access to ${repo}" >> ${GITHUB_STEP_SUMMARY}; exit 1)
curl -sS -f -I -H "Authorization: Bearer ${token}" https://api.github.com | grep 'x-oauth-scopes:' | grep 'repo' > /dev/null && exit 0 || echo "Token does not have repo scope on ${repo}" >> ${GITHUB_STEP_SUMMARY}
env:
repo: ${{ github.repository }}
token: ${{ secrets.GITHUB_TOKEN }}

# Set up java with maven cache
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
cache: 'maven'

# configure git
- name: Setup git config
run: |
git config user.name ${{ github.actor }}
git config user.email "<>"
# Check formatting and exit early (with success) if format is ok
- name: Check formatting
run: mvn spotless:check && ( echo "Source was already formatted, nothing was touched." >> $GITHUB_STEP_SUMMARY ; exit 0 )

# Apply formatting (changelog was touched)
- name: Apply formatting
run: mvn spotless:apply

# Commit changes
- name: Commit changes
run: git commit -m "Apply formatting rules"

# Push changes to branch
- name: Push changes to branch
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: git push origin

# print the summary
- name: Print summary
run: echo "Successfully formatted the source files and made a commit." >> $GITHUB_STEP_SUMMARY
28 changes: 20 additions & 8 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven

name: Java CI with Maven
name: CI Build

on:
push:
branches: [ "main" ]
pull_request_target:
branches:
- main
types:
- closed
pull_request:
branches: [ "main" ]
branches:
- main
workflow_dispatch:
inputs:
force_snapshot_release:
description: 'Update the snapshot release on github'
required: false
type: boolean

jobs:
build:
Expand All @@ -24,6 +33,9 @@ jobs:
distribution: 'temurin'
cache: maven

- name: Check if a snapshot release should be made and set environment variable
run: echo "MAKE_SNAPSHOT_RELEASE=${{ inputs.force_snapshot_release || (github.event.pull_request.base.ref == 'main' && github.event.action == 'closed' && github.event.pull_request.merged == true) }}" >> $GITHUB_ENV

# configure git
- name: setup git config
run: |
Expand All @@ -34,23 +46,23 @@ jobs:
run: mvn -Pzip install

- name: change tag 'snapshot' to current commit
if: ${{ github.event.pull_request.base.ref == 'main' && github.event.action == 'closed' && github.event.pull_request.merged == true}} # only make snapshot release if it is a push to main
if: ${{ env.MAKE_SNAPSHOT_RELEASE == 'true' }}
run: |
git tag -f snapshot
git push -f origin --tags
# Read version changelog
- id: get-changelog
name: Get version changelog
if: ${{ github.event.pull_request.base.ref == 'main' && github.event.action == 'closed' && github.event.pull_request.merged == true}} # only make snapshot release if it is a push to main
if: ${{ env.MAKE_SNAPSHOT_RELEASE == 'true' }}
uses: superfaceai/release-changelog-action@v1
with:
path-to-changelog: CHANGELOG.md
version: ${{ inputs.release_version }}
operation: read

- name: Make Release Body
if: ${{ github.event.pull_request.base.ref == 'main' && github.event.action == 'closed' && github.event.pull_request.merged == true}} # only make snapshot release if it is a push to main
if: ${{ env.MAKE_SNAPSHOT_RELEASE == 'true' }}
run: |
cat src/build/snapshot-release/release-body-header.md > target/release-body.md
echo "# Changes" >> target/release-body.md
Expand All @@ -60,7 +72,7 @@ jobs:
# Make github release
- name: Release
uses: softprops/action-gh-release@v2
if: ${{ github.event.pull_request.base.ref == 'main' && github.event.action == 'closed' && github.event.pull_request.merged == true}} # only make snapshot release if it is a push to main
if: ${{ env.MAKE_SNAPSHOT_RELEASE == 'true' }}
with:
name: Latest snapshot release
tag_name: snapshot
Expand Down

0 comments on commit db07f46

Please sign in to comment.