Skip to content
This repository has been archived by the owner on Mar 17, 2023. It is now read-only.

Commit

Permalink
Setup auto publish
Browse files Browse the repository at this point in the history
  • Loading branch information
3TUSK committed Jul 10, 2021
1 parent 74ea8d5 commit 47d953d
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 15 deletions.
69 changes: 69 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: release
on:
push:
tags:
- "**"
jobs:
publish:
runs-on: ubuntu-18.04
steps:
- name: Checkout
uses: actions/checkout@v2
with:
# Fetch all history
fetch-depth: 0
- name: Maven Publish
id: maven_publish
env:
ARCHIVE_ENDPOINT: ${{ secrets.TEACON_ARCHIVE_ENDPOINT }}
ARCHIVE_ACCESS_KEY: ${{ secrets.TEACON_ARCHIVE_ACCESS_KEY }}
ARCHIVE_SECRET_KEY: ${{ secrets.TEACON_ARCHIVE_SECRET_KEY }}
run: ./gradlew -Dorg.gradle.s3.endpoint=$ARCHIVE_ENDPOINT publishReleasePublicationToTeaconRepository githubActionOutput
- name: Generate Changelog
id: changelog
shell: bash
env:
CURRENT: ${{ github.ref }}
# Special thanks to this post on Stack Overflow regarding change set between two tags:
# https://stackoverflow.com/questions/12082981
# Do note that actions/checkout will enter detach mode by default, so you won't have
# access to HEAD ref. Use GitHub-Action-supplied `github.ref` instead.
# Special thanks to this issue ticket regarding escaping newline:
# https://github.com/actions/create-release/issues/25
# We use Bash parameter expansion to do find-and-replace.
# https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html
# Also we cannot use git rev-list because it always prepend "commit <hash>"
# See https://stackoverflow.com/questions/36927089/
run: |
current_tag=${CURRENT/refs\/tags\//}
last_tag=`git describe --tags --abbrev=0 "$current_tag"^ 2>/dev/null || echo`
if [ last_tag ]; then
changelog=`git log --pretty="format:%H: %s" ${last_tag}..$current_tag`
else
changelog=`git log --pretty="format:%H: %s"`
fi
changelog="${changelog//'%'/'%25'}"
changelog="${changelog//$'\n'/' %0A'}"
echo "::set-output name=value::Change set since ${last_tag:-the beginning}: %0A%0A$changelog"
- name: GitHub Release
id: create_release
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
draft: false
prerelease: false
body: |
${{ steps.changelog.outputs.value }}
- name: GitHub Release Artifact
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ steps.maven_publish.outputs.artifact_path }}
asset_name: ${{ steps.maven_publish.outputs.artifact_name }}
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types
asset_content_type: "application/java-archive"
31 changes: 16 additions & 15 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -106,30 +106,31 @@ publishing {
}
repositories {
maven {
name = "archive"
url = "https://maven.hub.tritusk.info/releases"
credentials {
username = System.env.MAVEN_USERNAME
password = System.env.MAVEN_PASSWORD
name = "teacon"
url = "s3://archive.teacon.org/maven/"
credentials(AwsCredentials) {
accessKey = System.env.ARCHIVE_ACCESS_KEY
secretKey = System.env.ARCHIVE_SECRET_KEY
}
}
}
}

// https://docs.gradle.org/current/userguide/signing_plugin.html
// https://gist.github.com/phit/bd3c6d156a2fa5f3b1bc15fa94b3256c
signing {
// GitHub Action environments provide GnuPG 2.2 so we can do this
if (System.env.GITHUB_ACTIONS) {
// TODO Allow forcing GnuPG
useGpgCmd()
}
sign publishing.publications.release
}
//signing {
// // TODO Sign release
// if (System.env.GITHUB_ACTIONS) {
// useGpgCmd()
// }
// sign publishing.publications.release
//}

tasks.withType(PublishToMavenRepository) {
onlyIf {
System.env.MAVEN_USERNAME && System.env.MAVEN_PASSWORD
if (repository && repository.name == 'teacon') {
onlyIf {
System.env.ARCHIVE_ACCESS_KEY && System.env.ARCHIVE_SECRET_KEY
}
}
}

Expand Down

0 comments on commit 47d953d

Please sign in to comment.