File size: 10,819 Bytes
3a478bf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
name: Release

on:
  push:
    branches:
      - main
      - master

jobs:
  release:
    name: Release
    runs-on: ubuntu-latest
    steps:
      - name: Check out the repository
        uses: actions/checkout@v4
        with:
          fetch-depth: 2

      - name: Set up Python
        uses: actions/[email protected]
        with:
          python-version: "3.8"

      - name: Detect and tag new version
        id: check-version
        uses: salsify/[email protected]
        with:
          tag-template: '{VERSION}'
          version-command: |
            bash -o pipefail -c "cat ./assets/config.json | jq -r '.version'"

      - name: Create CHANGELOG.md
        if: steps.check-version.outputs.tag
        run: |
          cd /home/runner/work/Applio/Applio
          cat > CHANGELOG.md << EOF
          ## Important Installation Guidelines

          ### Before You Install Applio
          Please review these essential instructions to ensure a smooth installation:

          - **File Location**: Place the Applio files in a dedicated folder on your C drive.
          - **Access Control**: Avoid placing Applio in folders that require elevated privileges.
          - **Administrator Rights**: Do not run the \`run-install.bat\` script with administrator privileges.
          - **Path Requirements**: Ensure the installation path is free of spaces or special characters.
          - **Security Settings**: Temporarily disable your antivirus and firewall to prevent any issues with missing dependencies during installation.

          ### Installation Steps
          1. **Download**: Get the .zip file from [this link](https://github.com/IAHispano/Applio/archive/refs/tags/${{ steps.check-version.outputs.tag }}.zip).
          2. **Run the Installer**: Extract the files and execute the \`run-install.bat\` script.
          3. **Start Applio**: Launch Applio by running the \`run-applio.bat\` script.

          ### Prefer a Simpler Installation?
          > [!TIP]
          > For the best experience, we highly recommend using the pre-compiled version. Compiling the code yourself may lead to instabilities.

          - **Download Compiled Version**: Get the zip from [this link](https://huggingface.co./IAHispano/Applio/resolve/main/Compiled/Windows/ApplioV${{ steps.check-version.outputs.tag }}.zip).
          - **Run Applio**: Extract the `.zip` file, then open the \`run-applio.bat\` file.

          **Full Changelog**: https://github.com/IAHispano/Applio/compare/${{ steps.check-version.outputs.previous-version }}...${{ steps.check-version.outputs.tag }}

          EOF

      - name: Get commit history
        if: steps.check-version.outputs.tag
        run: |
          previous_tag="${{ steps.check-version.outputs.previous-version }}"
          echo "Previous Tag: $previous_tag"

          commit_data=$(curl -s "https://api.github.com/repos/IAHispano/Applio/commits?sha=$previous_tag&per_page=1" \
            -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}")

          if [[ "$commit_data" == "[]" ]]; then
            echo "No commits found for tag $previous_tag. Using current date."
            commit_date=$(date -u +"%Y-%m-%dT%H:%M:%SZ") 
          else
            commit_date=$(echo "$commit_data" | jq -r '.[0].commit.committer.date')
          fi

          echo "Fetching commits since: $commit_date"
          curl -s "https://api.github.com/repos/IAHispano/Applio/commits?since=$commit_date&per_page=600" \
            -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
            | jq -r '.[] | .sha + " " + .commit.message' > commits.txt
          cat commits.txt

      - name: Summarize changelog with Groq API
        if: steps.check-version.outputs.tag
        id: summarize-changelog
        run: |
          changelog=$(cat commits.txt)
          json_payload=$(jq -n \
            --arg content "$changelog" \
            '{
              messages: [
                {
                  role: "system",
                  content: "You will receive a commit history. Your task is to extract and present the top 20% most relevant changes as a concise list, each item preceded by a bullet point (-). Each entry should be as brief as possible, ideally 1 to 4 words, summarizing the key updates and enhancements. Ignore changes related to .yml files, Git Keep, chore(format), \"colab,\" \"Major fix,\" and phrases like \"Updating Files\" or similar cases (e.g., \"Update Applio (train.py, preprocess.py, core.py)\"). Summarization Rules: Summarize commits like Update ___.py, Fix _____.py, Disable, Delete, or Merge as \"Fixing Code Issues\" and include specific details in parentheses only if they refer to a specific feature, module, or file name. For entries starting with \"Add,\" \"Fix,\" \"Improving,\" \"Improve,\" \"Rework,\" \"Update,\" or \"Updating,\" ensure they are merged into a single entry, with specific details included in parentheses. Ensure the details within parentheses are concise and directly relevant to the change, focusing on the affected feature or module. If multiple commits fall under \"Fixing Code Issues,\" consolidate them into one entry, mentioning only the major areas or modules affected without listing every specific fix. If the commit is related to \"tab\" or \"UI,\" merge it under \"Improving Code\" and include specific details in parentheses if necessary. Replace entries that use phrases like \"Updating Files\" or similar detailed updates (e.g., \"Update Applio (train.py, preprocess.py, core.py)\") with a summary of the actual changes or enhancements made, focusing on the specific impact or feature. Eliminate duplicates by merging similar entries into a single summary where possible. Ensure each entry is distinct and avoids repetition of similar details or terminology. Final Checks: After generating the list, review it to identify and merge any similar entries or duplicates. Ensure that each entry is concise, distinct, and free of redundancy. Limit the list to a maximum of 5 items. Each entry should start with an uppercase letter. Exclude any entries that include \"Major fix\" and ignore them if found. Note: Do not include any commentary or additional text; return only the list.  This prompt could be improved by adding examples of commit messages and their expected summaries to provide clearer guidance."
                },
                {
                  role: "user",
                  content: $content
                }
              ],
              model: "llama-3.1-70b-versatile",
              temperature: 0.6,
              max_tokens: 600,
              top_p: 1,
              stream: false,
              stop: null
            }')

          echo "json_payload: $json_payload"

          curl "https://api.groq.com/openai/v1/chat/completions" \
            -X POST \
            -H "Content-Type: application/json" \
            -H "Authorization: Bearer ${{ secrets.GROQ_API_KEY }}" \
            -d "$json_payload" \
            | jq -r '.choices[0].message.content' > summarized_changelog.txt

      - name: Set up Node.js
        if: steps.check-version.outputs.tag
        uses: actions/setup-node@v4
        with:
          node-version: 18

      - name: Install gh-release
        if: steps.check-version.outputs.tag
        run: |
          npm install https://github.com/Vidalnt/gh-release.git

      - name: Create package.json 
        if: steps.check-version.outputs.tag
        run: |
          cd /home/runner/work/Applio/Applio 
          echo '{}' > package.json
          jq \
            --arg version "${{ steps.check-version.outputs.tag }}" \
            --arg url "git+https://github.com/IAHispano/Applio.git" \
            '. + {version: $version, repository: {url: $url}}' \
            package.json > tmp.$$.json && mv tmp.$$.json package.json
          cat package.json

      - name: Publish release
        if: steps.check-version.outputs.tag
        run: |
          cd /home/runner/work/Applio/Applio && \
          tag_name="${{ steps.check-version.outputs.tag }}"
          changelog=$(cat summarized_changelog.txt)
          GH_RELEASE_GITHUB_API_TOKEN=${{ secrets.GITHUB_TOKEN }} npx gh-release \
            -t "${tag_name}" \
            -n "Release ${tag_name}" \
            -c "main" \
            -b "## Important Installation Guidelines

            ### Before You Install Applio
            Please review these essential instructions to ensure a smooth installation:
            - **File Location**: Place the Applio files in a dedicated folder on your C drive.
            - **Access Control**: Avoid placing Applio in folders that require elevated privileges.
            - **Administrator Rights**: Do not run the \`run-install.bat\` script with administrator privileges.
            - **Path Requirements**: Ensure the installation path is free of spaces or special characters.
            - **Security Settings**: Temporarily disable your antivirus and firewall to prevent any issues with missing dependencies during installation.
            ### Installation Steps
            1. **Download**: Get the .zip file from [this link](https://github.com/IAHispano/Applio/archive/refs/tags/${{ steps.check-version.outputs.tag }}.zip).
            2. **Run the Installer**: Extract the files and execute the \`run-install.bat\` script.
            3. **Start Applio**: Launch Applio by running the \`run-applio.bat\` script.
            ### Prefer a Simpler Installation?
            > [!TIP]
            > For the best experience, we highly recommend using the pre-compiled version. Compiling the code yourself may lead to instabilities.
            - **Download Compiled Version**: Get the zip from [this link](https://huggingface.co./IAHispano/Applio/resolve/main/Compiled/Windows/ApplioV${{ steps.check-version.outputs.tag }}.zip).
            - **Run Applio**: Extract the `.zip` file, then open the \`run-applio.bat\` file.
          ## What's New in This Release
            ${changelog}

          **Full Changelog**: https://github.com/IAHispano/Applio/compare/${{ steps.check-version.outputs.previous-version }}...${{ steps.check-version.outputs.tag }}  " \
            -o "IAHispano" \
            -r "Applio" \
            -w /home/runner/work/Applio/Applio \
            -y
        env:
          GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

      - name: Trigger Pre-Compiled
        if: steps.check-version.outputs.tag
        uses: actions/github-script@v6
        with:
          script: |
            await github.rest.actions.createWorkflowDispatch({
            owner: context.repo.owner,
            repo: context.repo.repo,
            workflow_id: 'pre_compiled.yml',
            ref: context.ref,
            });
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}