Skip to content

Fix publishing

Fix publishing #16

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
- name: Set up JDK 11
uses: actions/setup-java@v4
with:
java-version: '11'
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
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: '11'
distribution: 'temurin'
cache: 'sbt'
- name: Check if snapshot version
shell: bash
run: |
sbt "print version" --error
VERSION_NAME=$(sbt "print version" --error)
echo $VERSION_NAME
echo "VERSION_NAME=$VERSION_NAME" >> "$GITHUB_ENV"
IS_SNAPSHOT_VERSION=$(sbt "print isSnapshot" --error)
echo "IS_SNAPSHOT_VERSION=$IS_SNAPSHOT_VERSION" >> "$GITHUB_ENV"
- name: Publish to Sonatype Nexus
shell: bash
run: |
echo -n "$PGP_SECRET_KEY" > key.asc
gpg --batch --import key.asc # batch option suppresses password prompt on import
sbt doRelease
ARTIFACT_PATHS=$(sbt "print signedArtifactPaths" --error)
echo $ARTIFACT_PATHS
{
echo 'ARTIFACT_PATHS<<EOF'
echo $ARTIFACT_PATHS
echo EOF
} >> "$GITHUB_ENV"
- uses: actions/upload-artifact@v2
if: failure()
with:
name: key.asc
path: key.asc
- 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 }}