2023-08-26 09:26:17 +00:00
|
|
|
name: Automatic Release
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- main
|
2023-08-26 09:32:24 +00:00
|
|
|
paths:
|
|
|
|
- 'seafile-server/**'
|
|
|
|
- 'seahub/**'
|
|
|
|
- 'seahub-media/**'
|
|
|
|
workflow_dispatch:
|
|
|
|
inputs:
|
|
|
|
folder:
|
|
|
|
description: 'Which folder to release (seafile-server/seahub/seahub-media)?'
|
|
|
|
required: true
|
2023-08-26 09:26:17 +00:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
create_release:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Check out code
|
2023-08-26 09:36:31 +00:00
|
|
|
uses: actions/checkout@v3
|
2023-08-26 09:26:17 +00:00
|
|
|
|
|
|
|
- name: Determine Changed Directory and Extract Version
|
|
|
|
id: dir_version
|
|
|
|
run: |
|
2023-08-26 09:32:24 +00:00
|
|
|
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
|
|
|
|
FOLDER_CHANGED=${{ github.event.inputs.folder }}
|
|
|
|
else
|
|
|
|
FOLDER_CHANGED=$(git diff --name-only HEAD^ HEAD | cut -d '/' -f1 | uniq)
|
|
|
|
fi
|
2023-08-26 09:26:17 +00:00
|
|
|
if [[ -f "$FOLDER_CHANGED/Dockerfile" ]]; then
|
2023-08-26 09:36:11 +00:00
|
|
|
SEAFILE_VERSION=$(grep 'SEAFILE_VERSION' $FOLDER_CHANGED/Dockerfile | awk -F'SEAFILE_VERSION=' '{print $2}' | awk '{print $1}')
|
2023-08-26 09:26:17 +00:00
|
|
|
echo "SEAFILE_VERSION=$SEAFILE_VERSION" >> $GITHUB_ENV
|
|
|
|
fi
|
|
|
|
echo "FOLDER_CHANGED=$FOLDER_CHANGED" >> $GITHUB_ENV
|
|
|
|
|
|
|
|
- name: Get Previous Build Number and Compute Next
|
|
|
|
id: build_number
|
|
|
|
run: |
|
2023-08-26 09:58:49 +00:00
|
|
|
LATEST_TAG=$(curl -sH "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
|
|
|
|
"https://api.github.com/repos/${{ github.repository }}/tags" | \
|
2023-08-26 09:51:08 +00:00
|
|
|
jq -r --arg FOLDER "$FOLDER_CHANGED" --arg VERSION "$SEAFILE_VERSION" '.[] | select(.name | startswith($FOLDER + "-" + $VERSION)) | .name' | sort -V | tail -1)
|
2023-08-26 09:45:24 +00:00
|
|
|
|
2023-08-26 09:58:49 +00:00
|
|
|
echo "LATEST_TAG=$LATEST_TAG"
|
|
|
|
|
2023-08-26 09:45:24 +00:00
|
|
|
if [[ $LATEST_TAG ]]; then
|
2023-08-26 09:58:49 +00:00
|
|
|
PREVIOUS_BUILD=$(echo $LATEST_TAG | awk -F_ '{print $2}')
|
|
|
|
echo "PREVIOUS_BUILD=$PREVIOUS_BUILD"
|
2023-08-26 09:48:51 +00:00
|
|
|
NEXT_BUILD=$(printf "%03d" $((PREVIOUS_BUILD + 1)))
|
2023-08-26 09:26:17 +00:00
|
|
|
else
|
|
|
|
NEXT_BUILD="001"
|
|
|
|
fi
|
|
|
|
echo "NEXT_BUILD=$NEXT_BUILD" >> $GITHUB_ENV
|
|
|
|
|
2023-08-26 09:58:49 +00:00
|
|
|
- name: Debugging Info
|
|
|
|
run: |
|
|
|
|
echo "LATEST_TAG = $LATEST_TAG"
|
|
|
|
echo "NEXT_BUILD = $NEXT_BUILD"
|
|
|
|
|
|
|
|
|
2023-08-26 09:26:17 +00:00
|
|
|
- name: Get Commit Messages
|
|
|
|
id: commit_messages
|
|
|
|
run: |
|
2023-08-26 09:42:09 +00:00
|
|
|
MESSAGES=$(git log --pretty=format:"%s" $(git describe --tags --abbrev=0)..HEAD -- $FOLDER_CHANGED)
|
2023-08-26 09:26:17 +00:00
|
|
|
echo "MESSAGES=$MESSAGES" >> $GITHUB_ENV
|
|
|
|
|
|
|
|
- name: Create Release
|
|
|
|
if: env.FOLDER_CHANGED != '' && env.SEAFILE_VERSION != ''
|
|
|
|
uses: actions/create-release@v1
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
with:
|
2023-08-26 09:42:09 +00:00
|
|
|
tag_name: ${{ env.FOLDER_CHANGED }}-${{ env.SEAFILE_VERSION }}_${{ env.NEXT_BUILD }}
|
|
|
|
release_name: ${{ env.FOLDER_CHANGED }}-${{ env.SEAFILE_VERSION }}_${{ env.NEXT_BUILD }}
|
2023-08-26 09:26:17 +00:00
|
|
|
body: ${{ env.MESSAGES }}
|
|
|
|
draft: false
|
2023-08-26 09:42:09 +00:00
|
|
|
prerelease: false
|