Skip to content

Fix publishing

Fix publishing #23

Workflow file for this run

name: Continuous Integration
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
branches:
- '**'
create:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
pull_request:
workflow_dispatch:
permissions:
contents: write
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # needed for sbt-dynver to load all tags
fetch-tags: true
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: 'sbt'
- name: Run tests
run: sbt test
# Optional: This step uploads information to the GitHub dependency graph and unblocking Dependabot alerts for the repository
- name: Upload dependency graph
uses: scalacenter/sbt-dependency-submission@ab086b50c947c9774b70f39fc7f6e20ca2706c91
publish:
name: Publish
runs-on: ubuntu-latest
needs: [ test ]
if: (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags')) &&
(github.event_name == 'push' || github.event_name == 'create') &&
github.repository == 'tschuchortdev/hkd4s'
env:
SONATYPE_NEXUS_USERNAME: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
SONATYPE_NEXUS_PASSWORD: ${{ secrets.SONATYPE_NEXUS_PASSWORD }}
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
PGP_SECRET_KEY: ${{ secrets.PGP_SECRET_KEY }}
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # needed for sbt-dynver to load all tags
fetch-tags: true
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: 'sbt'
- name: Check if snapshot version
shell: bash
run: |
VERSION_NAME=$(sbt "print version" --error -Dsbt.log.noformat=true)
echo "VERSION_NAME=$VERSION_NAME" >> "$GITHUB_ENV"
IS_SNAPSHOT_VERSION=$(sbt "print isSnapshot" --error -Dsbt.log.noformat=true)
echo "IS_SNAPSHOT_VERSION=$IS_SNAPSHOT_VERSION" >> "$GITHUB_ENV"
- name: Publish to Sonatype Nexus
shell: bash
run: |
echo -n "$PGP_SECRET_KEY" | gpg --batch --import # batch option suppresses password prompt on import
echo "public keys:"
gpg --list-keys
echo "secret keys:"
gpg --list-secret-keys
sbt doRelease
ARTIFACT_PATHS=$(sbt "print signedArtifactPaths" --error -Dsbt.log.noformat=true)
echo $ARTIFACT_PATHS
{
echo 'ARTIFACT_PATHS<<EOF'
echo $ARTIFACT_PATHS
echo EOF
} >> "$GITHUB_ENV"
- name: Make release on Github
uses: marvinpinto/action-automatic-releases@latest
if: ${{ env.IS_SNAPSHOT_VERSION == 'false' }}
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
automatic_release_tag: ${{ env.VERSION_NAME }}
prerelease: false
title: ${{ env.VERSION_NAME }}
files: |
${{ env.ARTIFACT_PATHS }}