Skip to content

Commit

Permalink
💚 Fix/rework publishing workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
Komposten committed Jun 15, 2020
1 parent 703e61e commit e184345
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 72 deletions.
14 changes: 0 additions & 14 deletions .github/scripts/check_tag.sh

This file was deleted.

21 changes: 7 additions & 14 deletions .github/scripts/publish_docs.sh
Original file line number Diff line number Diff line change
@@ -1,28 +1,21 @@
#!/bin/bash

# Extract version number from GITHUB_REF
VERSION=${GITHUB_REF##*/}
MAJOR=$(echo $VERSION | grep -Eo "^[0-9]+")
echo "Detected major version $MAJOR"

# Check if version matches format major.minor.patch+build
if [[ $VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+(\+[0-9]+)?$ ]]
then
MAJOR=$(echo $VERSION | grep -Eo "^[0-9]+")
echo "Detected version $VERSION"
else
echo "Invalid version format: $VERSION"
exit 1
fi
# Clone komposten.github.io
git config --global user.email $GITHUB_EMAIL
git config --global user.name $GITHUB_USER
git clone --depth 1 https://${GITHUB_USER}:${GITHUB_TOKEN}@github.com/komposten/komposten.github.io.git

# Copy docs into the komposten.github.io repo
TARGET="komposten.github.io/leapjna/v$MAJOR"
echo "Copying javadocs to $TARGET"
cp -r LeapJna/target/site/apidocs/. $TARGET

# Enter the repo folder
cd komposten.github.io

# Create a new branch, commit and push
echo "Creating a new branch and committing the docs"
cd komposten.github.io
git checkout -b docs/leapjna-release-$VERSION
git add .
git commit -m ":pencil: Update LeapJna javadocs to ${VERSION}"
Expand Down
29 changes: 0 additions & 29 deletions .github/workflows/create_release.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,33 @@
name: Publish package and docs
name: Publish release

on:
release:
types: [published]

push:
tags:
- '[0-9]+.[0-9]+.[0-9]'
- '[0-9]+.[0-9]+.[0-9]+\+[0-9]+'

jobs:
release:
name: Publish release
runs-on: ubuntu-latest

steps:
- name: Checkout LeapJna
uses: actions/checkout@v2

- name: Extract tag
id: extract_tag
run: |
echo "::set-output name=tag::${GITHUB_REF##*/}"
- name: Publish release
env:
GITHUB_USER: ${{ secrets.GITHUB_ACTOR }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ steps.extract_tag.outputs.tag }}
run: |
hub release create -m "$VERSION" $VERSION
package:
name: Publish to GitHub Packages
runs-on: ubuntu-latest
Expand All @@ -19,9 +42,9 @@ jobs:
uses: actions/checkout@v2

- name: Publish package
run: mvn -B -DskipTests deploy --file pom.xml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: mvn -B -DskipTests deploy --file pom.xml

javadoc:
name: Publish JavaDocs
Expand All @@ -37,19 +60,22 @@ jobs:
uses: actions/checkout@v2
with:
path: 'LeapJna'

- name: Checkout komposten.github.io
uses: actions/checkout@v2
with:
repository: 'komposten/komposten.github.io'
path: 'komposten.github.io'

- name: Extract tag
id: extract_tag
run: |
echo "::set-output name=tag::${GITHUB_REF##*/}"
- name: Generate JavaDocs
run: |
cd LeapJna
mvn -B javadoc:javadoc --file pom.xml
- name: Publish JavaDocs
env:
VERSION: ${{ steps.extract_tag.outputs.tag }}
GITHUB_EMAIL: ${{ secrets.GH_EMAIL }}
GITHUB_USER: ${{ secrets.GH_USER }}
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
run: |
LeapJna/.github/scripts/publish_docs.sh
15 changes: 12 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,19 @@
<artifactId>LeapJna</artifactId>
<version>1.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<scm>
<developerConnection>scm:git:https://github.com/Komposten/LeapJna</developerConnection>
<tag>HEAD</tag>
</scm>
<tag>HEAD</tag>
</scm>

<distributionManagement>
<repository>
<id>github</id>
<name>GitHub Komposten Apache Maven Packages</name>
<url>https://maven.pkg.github.com/komposten/leapjna</url>
</repository>
</distributionManagement>

<properties>
<!-- General properties -->
Expand Down Expand Up @@ -115,6 +123,7 @@
<scmReleaseCommitComment>:bookmark: Release @{releaseLabel}</scmReleaseCommitComment>
<scmRollbackCommitComment>:rewind: Rollback release @{releaseLabel}</scmRollbackCommitComment>
<scmDevelopmentCommitComment>:camera_flash: Prepare for next development iteration</scmDevelopmentCommitComment>
<pushChanges>false</pushChanges>
</configuration>
</plugin>
</plugins>
Expand Down

0 comments on commit e184345

Please sign in to comment.