-
Notifications
You must be signed in to change notification settings - Fork 103
145 lines (123 loc) · 5.43 KB
/
Copy pathrelease.yaml
File metadata and controls
145 lines (123 loc) · 5.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
name: ESOUI Release
on:
workflow_dispatch:
schedule:
# every sunday at 22:15am
- cron: "15 22 * * 0"
jobs:
test:
if: github.repository_owner == 'm00nyONE'
uses: ./.github/workflows/_tests.yml
docs:
if: github.repository_owner == 'm00nyONE'
uses: ./.github/workflows/_generate-docs.yml
permissions:
contents: write
release:
if: github.repository_owner == 'm00nyONE'
name: "release"
runs-on: ubuntu-latest
permissions: write-all
needs: [ 'test' ]
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Check for changes since last release
id: check_changes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "🔍 Checking for changes since the last release..."
REPO="$GITHUB_REPOSITORY"
LAST_RELEASE_TAG=$(gh api repos/${GITHUB_REPOSITORY}/releases/latest --jq .tag_name || echo "")
if [ -z "$LAST_RELEASE_TAG" ] || [ "$LAST_RELEASE_TAG" = "null" ]; then
echo "⚠️ No previous release found, proceeding with release."
echo "should_release=true" >> $GITHUB_OUTPUT
exit 0
fi
echo "Last release tag: $LAST_RELEASE_TAG"
git fetch --quiet --tags
CHANGED=$(git diff --name-only "$LAST_RELEASE_TAG" HEAD | grep -E '\.(lua|txt|md|xml|addon|dds)$' || true)
if [ -z "$CHANGED" ]; then
echo "✅ No relevant file changes since $LAST_RELEASE_TAG."
echo "should_release=false" >> $GITHUB_OUTPUT
else
echo "✅ Changes detected:"
echo "$CHANGED"
echo "should_release=true" >> $GITHUB_OUTPUT
fi
- name: get repo name
run: echo "REPO_NAME=${{ github.event.repository.name }}" >> $GITHUB_ENV
- name: Get current year, month and day
if: steps.check_changes.outputs.should_release == 'true'
run: |
echo "BUILD_DATE_YEAR=$(date -u +'%Y')" >> $GITHUB_ENV
echo "BUILD_DATE_MONTH=$(date -u +'%m')" >> $GITHUB_ENV
echo "BUILD_DATE_DAY=$(date -u +'%d')" >> $GITHUB_ENV
echo "BUILD_DATE_NUMBER=$(date +'%Y%m%d')" >> $GITHUB_ENV
echo "BUILD_DATE_WITH_DOT=$(date +'%Y.%m.%d')" >> $GITHUB_ENV
echo "BUILD_DATE_WITH_HYPHEN=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
- name: Create env variables
if: steps.check_changes.outputs.should_release == 'true'
run: |
addon_name="${{ env.REPO_NAME }}"
version="${{ env.BUILD_DATE_WITH_HYPHEN }}"
echo "ADDON_NAME=$addon_name" >> $GITHUB_ENV
echo "ADDON_VERSION=$version" >> $GITHUB_ENV
echo "ZIP_FULL_NAME=${addon_name}-${version}.zip" >> $GITHUB_ENV
- name: Replace placeholders with current date
if: steps.check_changes.outputs.should_release == 'true'
run: |
sed -i "s/version = \"dev\"/version = \"${{ env.ADDON_VERSION }}\"/g" ${{ env.ADDON_NAME }}.lua
sed -i "s/## Version: dev/## Version: ${{ env.ADDON_VERSION }}/g" ${{ env.ADDON_NAME }}.addon
sed -i "s/## AddOnVersion: 99999999/## AddOnVersion: ${{ env.BUILD_DATE_NUMBER }}/g" ${{ env.ADDON_NAME }}.addon
- name: Create ZIP archive
if: steps.check_changes.outputs.should_release == 'true'
run: |
REPO_FOLDER=$(pwd)
TMP_FOLDER="/tmp/${{ env.ADDON_NAME }}"
# Define the path to the ignore pattern file
ignore_file=".build-ignore"
# Read and process ignore patterns into a single line
exclude_patterns=$(cat "$ignore_file" | awk '{print "--exclude " $0}' | tr '\n' ' ')
# Make folder and copy content
mkdir -p $TMP_FOLDER
rsync -a --quiet $exclude_patterns "$REPO_FOLDER/" "$TMP_FOLDER/"
# create zip
(cd /tmp && zip -r --quiet "$REPO_FOLDER/${{ env.ZIP_FULL_NAME }}" "${{ env.ADDON_NAME }}")
- name: Extract latest changelog entry
if: steps.check_changes.outputs.should_release == 'true'
run: |
awk '/^## / { if (!found) { found=1; print; next } else { exit } } found' CHANGELOG.md > latest_changes.md
cat latest_changes.md
- name: Create GitHub Release
uses: ncipollo/release-action@v1
if: steps.check_changes.outputs.should_release == 'true'
with:
name: "${{ env.ADDON_VERSION }}"
commit: ${{ github.ref }}
tag: "${{ env.ADDON_VERSION }}"
artifacts: "${{ env.ZIP_FULL_NAME }}"
artifactContentType: application/zip
bodyFile: latest_changes.md
allowUpdates: true
makeLatest: true
- name: Test Upload to ESOUI
uses: m00nyONE/esoui-upload@main
if: steps.check_changes.outputs.should_release == 'true'
with:
api_key: ${{ secrets.ESOUI_API_KEY }}
addon_id: '4161'
version: ${{ env.ADDON_VERSION }}
zip_file: ${{ env.ZIP_FULL_NAME }}
changelog_file: 'CHANGELOG.md'
test: true
- name: Upload to ESOUI
uses: m00nyONE/esoui-upload@main
if: steps.check_changes.outputs.should_release == 'true'
with:
api_key: ${{ secrets.ESOUI_API_KEY }}
addon_id: '4161'
version: ${{ env.ADDON_VERSION }}
zip_file: ${{ env.ZIP_FULL_NAME }}
changelog_file: 'CHANGELOG.md'