cwlScala Release #23
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# TODO: update conda-forge recipe | |
name: cwlScala Release | |
on: | |
workflow_dispatch: | |
inputs: | |
release-version: | |
description: 'Release version' | |
required: true | |
permissions: | |
contents: write | |
packages: write | |
jobs: | |
run-release: | |
name: cwlScala Release | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Git checkout | |
uses: actions/checkout@v2 | |
with: | |
submodules: true | |
- name: Version check | |
run: | | |
snapshot=`grep -c "SNAPSHOT" ./src/main/resources/application.conf || true` | |
if [ "$snapshot" -ne "0" ]; then | |
echo "cwlScala version contains '-SNAPSHOT'; releases cannot have snapshot versions" | |
exit 1 | |
fi | |
- name: Install java | |
uses: actions/setup-java@v1 | |
with: | |
java-version: 11 | |
- name: Install & build | |
run: | | |
# compile antlr4 sources | |
cd ${GITHUB_WORKSPACE} | |
make | |
- name: Compile & Test | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
sbt scalafmtCheckAll | |
sbt test | |
- name: Assembly | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
sbt assembly | |
mv ./target/cwlScala.jar ./cwlScala-${{ github.event.inputs.release-version }}.jar | |
- name: Extract release notes and set version in application.conf files | |
id: update-release | |
run: | | |
# Update the config file with the newest version | |
sed -i 's/version.*$/version = "${{ github.event.inputs.release-version }}"/' ./src/main/resources/application.conf | |
# Extract release notes for the release into a temporary (unpushed) file | |
# It is expected the RELEASE_NOTES.md has already an entry for the version being | |
# released. The section should start with '## <version>', e.g. ## 1.0.0 2021-01-01 | |
# The file will be read by the create-release step | |
RELEASE_NOTES_PATH="./release_notes_${{ github.event.inputs.release-version }}.md" | |
sed -n '/## ${{ github.event.inputs.release-version }}/,/##/p' RELEASE_NOTES.md | sed '1d; $d' > $RELEASE_NOTES_PATH | |
echo ::set-output name=release-notes-path::$(echo "${RELEASE_NOTES_PATH}") | |
- name: Commit changes to application.conf files | |
uses: EndBug/add-and-commit@v7 | |
with: | |
message: 'Release ${{ github.event.inputs.release-version }}' | |
add: '[ | |
"./src/main/resources/application.conf" | |
]' | |
push: false | |
tag: ${{ github.event.inputs.release-version }} | |
- name: Create release entry | |
id: create-release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ github.event.inputs.release-version }} | |
release_name: cwlScala ${{ github.event.inputs.release-version }} | |
body_path: ${{ steps.update-release.outputs.release-notes-path }} | |
draft: true | |
prerelease: false | |
- name: Upload assembly JAR | |
id: upload-release-assembly | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
# This pulls from the "Create release entry" step above, referencing it's ID to get its outputs object, | |
# which include a `upload_url`. See this blog post for more info: | |
# https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps | |
upload_url: ${{ steps.create-release.outputs.upload_url }} | |
asset_path: ./cwlScala-${{ github.event.inputs.release-version }}.jar | |
asset_name: cwlScala-${{ github.event.inputs.release-version }}.jar | |
asset_content_type: application/jar | |
- name: Push local release branch and tag to origin | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
git push origin HEAD:${{ github.ref }} | |
git push origin HEAD:${{ github.event.inputs.release-version }} | |
- name: Publish package | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
sbt publish | |
- name: Rollback release if unsuccessfull | |
if: ${{ cancelled() || failure() }} | |
uses: author/action-rollback@stable | |
with: | |
release_id: ${{ steps.create-release.outputs.id }} | |
tag: ${{ github.event.inputs.release-version }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |