|
| 1 | +name: Create release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + commit_hash: |
| 7 | + description: "Hash of 'Release version x.y.z' commit" |
| 8 | + required: true |
| 9 | + |
| 10 | +jobs: |
| 11 | + build: |
| 12 | + name: Create Release |
| 13 | + runs-on: ubuntu-latest |
| 14 | + steps: |
| 15 | + - name: Checkout code |
| 16 | + uses: actions/checkout@v2 |
| 17 | + with: |
| 18 | + ref: ${{ github.event.inputs.commit_hash }} |
| 19 | + |
| 20 | + - name: Check commit title and extract version |
| 21 | + run: | |
| 22 | + export commit_title=$(git log --pretty=format:%s -1 ${{ github.event.inputs.commit_hash }}) |
| 23 | + echo "Commit title: $commit_title" |
| 24 | + if [[ $commit_title =~ ^Release\ version\ [0-9]*\.[0-9]*\.[0-9]*$ ]]; then |
| 25 | + echo "Valid commit title" |
| 26 | + else |
| 27 | + echo "Invalid commit title" |
| 28 | + exit 1 |
| 29 | + fi |
| 30 | + export version=$(echo ${commit_title} | sed s/^Release\ version\ //g) |
| 31 | + echo "Will use version ${version}" |
| 32 | + echo "version=${version}" >> $GITHUB_ENV |
| 33 | +
|
| 34 | + - name: Build |
| 35 | + run: | |
| 36 | + ./gradlew distTar distZip |
| 37 | +
|
| 38 | + export tar_file=$(ls ./build/distributions/ | grep tar) |
| 39 | + export zip_file=$(ls ./build/distributions/ | grep zip) |
| 40 | + echo tar_file=${tar_file} >> $GITHUB_ENV |
| 41 | + echo zip_file=${zip_file} >> $GITHUB_ENV |
| 42 | +
|
| 43 | + echo tar_path=`realpath ./build/distributions/${tar_file}` >> $GITHUB_ENV |
| 44 | + echo zip_path=`realpath ./build/distributions/${zip_file}` >> $GITHUB_ENV |
| 45 | +
|
| 46 | + - name: Create release draft |
| 47 | + id: create_release |
| 48 | + uses: actions/create-release@v1 |
| 49 | + env: |
| 50 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 51 | + with: |
| 52 | + tag_name: "v${{ env.version }}" |
| 53 | + release_name: "v${{ env.version }}" |
| 54 | + body: | |
| 55 | + *Fill in* |
| 56 | + draft: true |
| 57 | + prerelease: false |
| 58 | + |
| 59 | + - name: Upload tar |
| 60 | + uses: actions/upload-release-asset@v1 |
| 61 | + env: |
| 62 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 63 | + with: |
| 64 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 65 | + asset_path: ${{ env.tar_path }} |
| 66 | + asset_name: ${{ env.tar_file }} |
| 67 | + asset_content_type: application/tar |
| 68 | + |
| 69 | + - name: Upload zip |
| 70 | + uses: actions/upload-release-asset@v1 |
| 71 | + env: |
| 72 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 73 | + with: |
| 74 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 75 | + asset_path: ${{ env.zip_path }} |
| 76 | + asset_name: ${{ env.zip_file }} |
| 77 | + asset_content_type: application/zip |
0 commit comments