diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..2e747fc --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,54 @@ +name: Publish to Maven Central + +on: + release: + types: [ created ] + +jobs: + publish: + name: Publish to Maven Central + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + java-version: '21' + distribution: corretto + server-id: central + server-username: SERVER_USERNAME + server-password: SERVER_PASSWORD + gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} + gpg-passphrase: GPG_PASSPHRASE + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.12' + + - name: Install test file generator requirements + run: | + pip install -r test-requirements.txt + + - name: Locate Python + id: locate-python + run: echo "python-path=$(which python)" >> "$GITHUB_OUTPUT" + + - name: Set version from release tag + run: mvn versions:set -DnewVersion="${REF_NAME#v}" + env: + REF_NAME: ${{ github.ref_name }} + + - name: Publish + run: mvn --batch-mode deploy + env: + ASDF_JAVA_TESTS_PYTHON_PATH: ${{ steps.locate-python.outputs.python-path }} + SERVER_USERNAME: ${{ secrets.CENTRAL_USERNAME }} + SERVER_PASSWORD: ${{ secrets.CENTRAL_TOKEN }} + GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}