2023-08-26 09:26:17 +00:00
|
|
|
name: Automatic Release
|
|
|
|
|
|
|
|
on:
|
2023-08-27 12:21:26 +00:00
|
|
|
schedule:
|
|
|
|
- cron: '0 0 * * *' # Scheduled to run every day at midnight
|
2023-08-27 12:34:52 +00:00
|
|
|
workflow_dispatch: {}
|
2023-08-26 09:26:17 +00:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
create_release:
|
|
|
|
runs-on: ubuntu-latest
|
2023-08-30 12:33:37 +00:00
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
2023-08-26 13:56:50 +00:00
|
|
|
strategy:
|
|
|
|
matrix:
|
2023-08-27 08:50:24 +00:00
|
|
|
folder: ['seafile-server', 'seahub', 'seahub-media', 'seafile-caddy']
|
2023-08-26 13:56:50 +00:00
|
|
|
fail-fast: false
|
2023-08-27 12:21:26 +00:00
|
|
|
|
2023-08-26 09:26:17 +00:00
|
|
|
steps:
|
|
|
|
- name: Check out code
|
2023-09-22 18:43:13 +00:00
|
|
|
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4
|
2023-08-26 10:30:20 +00:00
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
2023-08-26 09:26:17 +00:00
|
|
|
|
2023-08-27 12:34:52 +00:00
|
|
|
- name: Get Previous Tag and Build Number
|
|
|
|
id: build_number
|
|
|
|
run: |
|
2023-09-09 11:50:02 +00:00
|
|
|
LATEST_TAG=$(git describe --tags --abbrev=0 --match "${{ matrix.folder }}-*" 2>/dev/null)
|
2023-08-27 12:34:52 +00:00
|
|
|
echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_ENV
|
|
|
|
|
2023-10-19 09:27:28 +00:00
|
|
|
PREVIOUS_VERSION=$(echo $LATEST_TAG | awk -F'[-_]' '{print $(NF-1)}')
|
2023-10-18 19:38:30 +00:00
|
|
|
PREVIOUS_BUILD=$(echo $LATEST_TAG | awk -F_ '{print $2}')
|
|
|
|
|
|
|
|
if [[ "${{ matrix.folder }}" == "seafile-caddy" ]]; then
|
|
|
|
CURRENT_VERSION=$(grep -m 1 'FROM caddy:' ${{ matrix.folder }}/Dockerfile | awk -F':' '{print $2}' | awk -F'-' '{print $1}' | tr -d '\n')
|
2023-08-27 12:34:52 +00:00
|
|
|
else
|
2023-10-18 19:38:30 +00:00
|
|
|
CURRENT_VERSION=$(grep -m 1 'SEAFILE_VERSION' ${{ matrix.folder }}/Dockerfile | awk -F'SEAFILE_VERSION=' '{print $2}' | awk '{print $1}' | tr -d '\n')
|
|
|
|
fi
|
2023-10-19 09:27:28 +00:00
|
|
|
echo "CURRENT_VERSION=$CURRENT_VERSION" >> $GITHUB_ENV
|
2023-10-18 19:38:30 +00:00
|
|
|
|
|
|
|
if [[ "$PREVIOUS_VERSION" != "$CURRENT_VERSION" ]] || [[ -z "$LATEST_TAG" ]]; then
|
2023-08-27 12:34:52 +00:00
|
|
|
NEXT_BUILD="001"
|
2023-10-18 19:38:30 +00:00
|
|
|
else
|
|
|
|
NEXT_BUILD=$(printf "%03d" $((PREVIOUS_BUILD + 1)))
|
2023-08-27 12:34:52 +00:00
|
|
|
fi
|
|
|
|
echo "NEXT_BUILD=$NEXT_BUILD" >> $GITHUB_ENV
|
|
|
|
|
2023-10-19 09:27:28 +00:00
|
|
|
- name: Determine Changed Directory
|
2023-08-26 09:26:17 +00:00
|
|
|
id: dir_version
|
|
|
|
run: |
|
2023-08-27 12:34:52 +00:00
|
|
|
if [[ -z "$LATEST_TAG" ]]; then
|
|
|
|
COMMIT_RANGE="--all"
|
2023-08-26 09:32:24 +00:00
|
|
|
else
|
2023-08-27 12:34:52 +00:00
|
|
|
COMMIT_RANGE="${LATEST_TAG}..HEAD"
|
2023-08-26 09:32:24 +00:00
|
|
|
fi
|
2023-09-09 11:56:17 +00:00
|
|
|
echo "COMMIT_RANGE=${LATEST_TAG}..HEAD" >> $GITHUB_ENV
|
|
|
|
|
2023-08-27 12:34:52 +00:00
|
|
|
CHANGED_FOLDERS=$(git diff --name-only $COMMIT_RANGE | cut -d '/' -f1 | uniq)
|
|
|
|
[[ "$CHANGED_FOLDERS" =~ "${{ matrix.folder }}" ]] && FOLDER_CHANGED="${{ matrix.folder }}" || FOLDER_CHANGED=""
|
|
|
|
|
2023-08-26 13:56:50 +00:00
|
|
|
if [ -z "$FOLDER_CHANGED" ]; then
|
2023-08-27 12:49:52 +00:00
|
|
|
echo "PROCEED=false" >> $GITHUB_ENV
|
2023-08-27 12:36:18 +00:00
|
|
|
exit 0
|
2023-08-26 13:56:50 +00:00
|
|
|
fi
|
2023-08-26 15:26:38 +00:00
|
|
|
echo "FOLDER_CHANGED=$FOLDER_CHANGED" >> $GITHUB_ENV
|
2023-08-27 12:21:26 +00:00
|
|
|
|
2023-08-30 12:33:37 +00:00
|
|
|
- name: Get Commit Messages and Write to Markdown
|
2023-08-27 12:49:52 +00:00
|
|
|
if: env.PROCEED != 'false'
|
2023-08-26 10:42:27 +00:00
|
|
|
id: get_messages
|
2023-08-26 09:26:17 +00:00
|
|
|
run: |
|
2023-08-26 10:14:54 +00:00
|
|
|
MESSAGES=""
|
2023-08-26 10:25:44 +00:00
|
|
|
for commit in $(git log --pretty=format:'%H' $COMMIT_RANGE); do
|
|
|
|
if git diff-tree --no-commit-id --name-only -r $commit | grep "^$FOLDER_CHANGED/"; then
|
|
|
|
MESSAGE=$(git log --format=%B -n 1 $commit)
|
2023-08-26 10:42:27 +00:00
|
|
|
MESSAGES="$MESSAGES- $commit: $MESSAGE"$'\n'
|
2023-08-26 10:25:44 +00:00
|
|
|
fi
|
2023-08-26 10:14:54 +00:00
|
|
|
done
|
2023-08-27 12:21:26 +00:00
|
|
|
|
|
|
|
if [ -z "$MESSAGES" ]; then
|
2023-08-27 12:49:52 +00:00
|
|
|
echo "PROCEED=false" >> $GITHUB_ENV
|
2023-08-27 12:36:18 +00:00
|
|
|
exit 0
|
2023-08-27 11:58:14 +00:00
|
|
|
fi
|
2023-08-26 10:36:03 +00:00
|
|
|
|
2023-08-27 08:50:24 +00:00
|
|
|
if [[ "$FOLDER_CHANGED" == "seafile-caddy" ]]; then
|
2023-10-19 09:27:28 +00:00
|
|
|
echo "Caddy version: $CURRENT_VERSION" > RELEASE_NOTES.md
|
2023-08-27 08:50:24 +00:00
|
|
|
else
|
2023-10-19 09:27:28 +00:00
|
|
|
echo "Seafile version: $CURRENT_VERSION" > RELEASE_NOTES.md
|
2023-08-27 08:50:24 +00:00
|
|
|
fi
|
2023-08-30 12:33:37 +00:00
|
|
|
echo "Image build version: $NEXT_BUILD" >> RELEASE_NOTES.md
|
|
|
|
echo "Changelog:" >> RELEASE_NOTES.md
|
|
|
|
echo -e "$MESSAGES" >> RELEASE_NOTES.md
|
2023-08-26 09:26:17 +00:00
|
|
|
|
2023-08-30 12:33:37 +00:00
|
|
|
- name: Create and Upload GitHub Release
|
2023-08-27 12:49:52 +00:00
|
|
|
if: env.PROCEED != 'false'
|
2023-08-30 12:33:37 +00:00
|
|
|
run: |
|
2023-10-19 09:27:28 +00:00
|
|
|
gh release create ${{ env.FOLDER_CHANGED }}-${{ env.CURRENT_VERSION }}_${{ env.NEXT_BUILD }} \
|
|
|
|
-t ${{ env.FOLDER_CHANGED }}-${{ env.CURRENT_VERSION }}_${{ env.NEXT_BUILD }} \
|
2023-08-30 12:33:37 +00:00
|
|
|
-F RELEASE_NOTES.md \
|
|
|
|
--draft=false \
|
2023-09-09 11:35:29 +00:00
|
|
|
--prerelease=false
|