mirror of
https://github.com/yushijinhun/authlib-injector.git
synced 2024-11-15 06:11:09 +01:00
100 lines
4 KiB
YAML
100 lines
4 KiB
YAML
name: create_release
|
|
on:
|
|
repository_dispatch:
|
|
types: [release_proposal_submit]
|
|
jobs:
|
|
create_release:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- id: parse_pr
|
|
name: Parse pull request
|
|
shell: bash
|
|
run: |
|
|
pr=$(curl -Ss "${{ github.event.client_payload.pull }}")
|
|
pr_body=$(jq --raw-output '.body' <<< $pr)
|
|
if [ "$pr_body" == "" ]; then
|
|
echo "::error ::pull request body is empty."
|
|
exit 1
|
|
fi
|
|
|
|
prev_build_number=$(curl -Ss 'https://raw.githubusercontent.com/yushijinhun/authlib-injector.yushi.moe/master/artifacts.json' | jq -r '.artifacts|max_by(.build_number).build_number')
|
|
echo "prev_build_number=$prev_build_number"
|
|
build_number=$(grep -Pom1 '@@release_proposal\.build_number=\K.*(?=@@)' <<< $pr_body) || {
|
|
echo "no build number specified, using auto-increment build number."
|
|
build_number=$(( $prev_build_number + 1 ))
|
|
}
|
|
if (( $build_number <= $prev_build_number )); then
|
|
echo "::error ::specified build number is too small ($build_number)."
|
|
exit 1
|
|
fi
|
|
echo "::set-output name=build_number::$build_number"
|
|
|
|
version_number=$(grep -Pom1 '@@release_proposal\.version_number=\K.*(?=@@)' <<< $pr_body) || {
|
|
echo "::error ::release_proposal.version_number is not set."
|
|
exit 1
|
|
}
|
|
echo "::set-output name=version_number::$version_number"
|
|
|
|
release_notes=$(grep -oz '<!--changes_begin-->.*<!--changes_end-->' <<< $pr_body) || {
|
|
release_notes=$pr_body
|
|
}
|
|
echo "::set-output name=release_notes::$(jq --null-input -c '.text=$text' --arg text "$release_notes")"
|
|
|
|
echo "::set-output name=commit::$(jq --raw-output '.merge_commit_sha' <<< $pr)"
|
|
echo "::set-output name=pr::$(jq --raw-output '.number' <<< $pr)"
|
|
|
|
- id: create_release
|
|
name: Create release
|
|
uses: fleskesvor/create-release@feature/support-target-commitish
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
with:
|
|
tag_name: v${{ steps.parse_pr.outputs.version_number }}
|
|
commitish: ${{ steps.parse_pr.outputs.commit }}
|
|
release_name: v${{ steps.parse_pr.outputs.version_number }}
|
|
draft: true
|
|
body: |
|
|
<!--
|
|
@@release.build_number=${{ steps.parse_pr.outputs.build_number }}@@
|
|
@@release.version_number=${{ steps.parse_pr.outputs.version_number }}@@
|
|
@@release.pr=${{ steps.parse_pr.outputs.pr }}@@
|
|
@@release.trigger_deploy@@
|
|
-->
|
|
${{ fromJSON(steps.parse_pr.outputs.release_notes).text }}
|
|
|
|
Linked pull request: [#${{ steps.parse_pr.outputs.pr }}](https://github.com/${{ github.repository }}/pull/${{ steps.parse_pr.outputs.pr }})
|
|
Build number: ${{ steps.parse_pr.outputs.build_number }}
|
|
|
|
- name: Checkout
|
|
uses: actions/checkout@v2
|
|
with:
|
|
ref: ${{ steps.parse_pr.outputs.commit }}
|
|
|
|
- name: Setup JDK 8
|
|
uses: actions/setup-java@v1
|
|
with:
|
|
java-version: 8
|
|
|
|
- id: build
|
|
name: Build
|
|
shell: bash
|
|
run: |
|
|
export AI_BUILD_NUMBER=${{ steps.parse_pr.outputs.build_number }}
|
|
export AI_VERSION_NUMBER=${{ steps.parse_pr.outputs.version_number }}
|
|
gradle
|
|
gradle test
|
|
asset_path=$(echo build/libs/*.jar)
|
|
echo "Build output is at $asset_path"
|
|
echo "::set-output name=asset_path::$asset_path"
|
|
echo "::set-output name=asset_name::$(basename "$asset_path")"
|
|
|
|
- name: Upload assets to GitHub Releases
|
|
uses: actions/upload-release-asset@v1
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
with:
|
|
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
|
asset_path: ${{ steps.build.outputs.asset_path }}
|
|
asset_name: ${{ steps.build.outputs.asset_name }}
|
|
asset_content_type: "application/java-archive"
|
|
|