File: prepare_release.yml

package info (click to toggle)
sqlitestudio 3.4.21%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 54,880 kB
  • sloc: ansic: 406,208; cpp: 123,872; yacc: 2,692; tcl: 497; sh: 462; xml: 426; makefile: 19
file content (250 lines) | stat: -rw-r--r-- 9,195 bytes parent folder | download
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
env:
    RELEASE_META: |
        {
            "win64_release": {
                "os": "Windows x64",
                "installer_url": "",
                "portable_url": ""
            },
            "win32_release": {
                "os": "Windows i386",
                "installer_url": "",
                "portable_url": ""
            },
            "mac_release": {
                "os": "MacOS X x64",
                "installer_url": "",
                "portable_url": ""
            },
            "lin_release": {
                "os": "Linux x64",
                "installer_url": "",
                "portable_url": ""
            }
        }
    BRANCH_NAME: ${{ github.head_ref || github.ref_name }}

name: Prepare version release

on:
    workflow_dispatch:
        inputs:
          RUN_IDS_TO_USE:
            description: 'Existing RUN IDs to use instead of a fresh build'
            required: false
            default: ''
            type: string
          TEST_RUN:
            description: 'Test run (-test suffix for release)'
            required: false
            type: boolean
            default: false
          DEBUG:
            description: 'Enable workflow debug messages'
            required: false
            type: boolean
            default: false

jobs:
    build:
        runs-on: ubuntu-22.04

        steps:
            - name: Clone GH scripts
              uses: actions/checkout@v3
              with:
                repository: pawelsalawa/gh-action-scripts
                ref: main

            - name: Set environment variables for scripts
              run: |
                echo "REPO=${{ github.repository }}" >> $GITHUB_ENV
                echo "TOKEN=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_ENV
                chmod +x scripts/*.sh
                echo "SCRIPTS=$(pwd)/scripts" >> $GITHUB_ENV
                echo "DEBUG=${{ inputs.DEBUG }}" >> $GITHUB_ENV

            - name: Trigger binary build workflows
              shell: bash
              if: inputs.RUN_IDS_TO_USE == ''
              run: |
                WORKFLOWS=()
                for key in $(echo "$RELEASE_META" | jq -r 'keys[]')
                do
                    WORKFLOWS+=("$key.yml")
                done
                echo "Workflows to trigger: ${WORKFLOWS[@]}"
                echo "WORKFLOWS=${WORKFLOWS[@]}" >> $GITHUB_ENV
              
                run_ids=()
                
                inputs="{}"
                if [ "${DEBUG}" = "true" ]
                then
                    inputs=$(echo $inputs | jq -c '.DEBUG = "true"')
                fi
                
                for wname in ${WORKFLOWS[@]}
                do
                    run_id=$($SCRIPTS/run_workflow.sh $wname "$inputs" "${{ github.ref_name }}")
                    run_ids+=( $run_id )
                done
                echo "CHILD_IDS=${run_ids[@]}" >> $GITHUB_ENV

            - name: Wait for workflows to complete
              shell: bash
              if: inputs.RUN_IDS_TO_USE == ''
              run: |
                echo "Workflow IDs to wait for: $CHILD_IDS"
                success=0
                for runid in $CHILD_IDS
                do
                    success=$($SCRIPTS/wait_for_run.sh $runid 50)
                    if [ $success -eq 1 ]
                    then
                        echo "Child build $runid finished successfully."
                    else
                        echo "Child build $runid failed."
                        exit 1
                    fi
                done
                echo "All child workflows finished successfully."

            - name: Determin final RUN IDs
              shell: bash
              run: |
                if [ "${{ inputs.RUN_IDS_TO_USE }}" != "" ]
                then
                    CHILD_IDS="${{ inputs.RUN_IDS_TO_USE }}"
                    echo "CHILD_IDS=$CHILD_IDS" >> $GITHUB_ENV
                fi

            - name: Get SQLiteStudio version
              shell: bash
              run: |
                ref="${{ env.BRANCH_NAME }}"
                url="https://raw.githubusercontent.com/pawelsalawa/sqlitestudio/refs/heads/$ref/SQLiteStudio3/coreSQLiteStudio/sqlitestudio.cpp"
                int_ver=$(curl -s -L $url | grep "static const int sqlitestudioVersion" | grep -o "[0-9]*")
                SQLITESTUDIO_VERSION=$($SCRIPTS/convert_int_ver.sh $int_ver)
                echo "SQLITESTUDIO_VERSION=$SQLITESTUDIO_VERSION" >> $GITHUB_ENV

            - name: Download artifacts
              shell: bash
              run: |
                mkdir assets
                cd assets
                
                for runid in ${{ env.CHILD_IDS }}
                do
                    resp=$($SCRIPTS/query_run.sh $runid)
                    
                    workflow_file=$(basename $(echo "$resp" | jq -r '.path'))
                    REL_NAME="${workflow_file%.*}"
                    
                    mkdir $REL_NAME
                    cd $REL_NAME
                    
                    $SCRIPTS/download_artifacts.sh $runid
                    
                    cd ..
                done
                
                echo "Downloaded files:"
                find .

            - name: Create a draft release
              shell: bash
              working-directory: assets
              run: |
                tag_name="$SQLITESTUDIO_VERSION"
                rel_name="$SQLITESTUDIO_VERSION release"
                if [ "${{ inputs.TEST_RUN }}" == "true" ]
                then
                    tag_name="${tag_name}-test"
                    rel_name="${rel_name}-test"
                fi
                echo "TAG_NAME=$tag_name" >> $GITHUB_ENV
                
                releaseid=$($SCRIPTS/create_draft_release.sh "$tag_name" "$BRANCH_NAME" "$rel_name" "")
                echo "RELEASE_ID: $releaseid"
                echo "RELEASE_ID=$releaseid" >> $GITHUB_ENV
                
            - name: Upload assets
              shell: bash
              working-directory: assets
              run: |
                NEW_META=$(echo "$RELEASE_META" | jq -c '.')
                for dir in *
                do
                    cd $dir
                    
                    for file in *
                    do
                        unzip $file
                        rm -f $file
                        file="${file%.*}"
                    
                        if [[ "$file" == *"installer"* ]]
                        then
                            url_type=installer_url
                        else
                            url_type=portable_url
                        fi

                        echo "Uploading $file..."
                        url=$($SCRIPTS/upload_artifact.sh $RELEASE_ID "$file")
                        url=$(echo $url | sed -E "s/untagged-[^\/]*/$SQLITESTUDIO_VERSION/")
                        echo "Download url for $file is: $url"

                        NEW_META=$(
                            echo "$NEW_META" | \
                                jq -c \
                                   --arg dir "$dir" \
                                   --arg url "$url" \
                                   --arg url_type "$url_type" \
                                   '.[$dir][$url_type] = $url'
                           )
                    done
                    
                    cd ..
                done
                
                echo "META after uploads:"
                echo "$NEW_META" | jq '.'
                echo "RELEASE_META=$NEW_META" >> $GITHUB_ENV
                
            - name: Update release description
              shell: bash
              working-directory: assets
              run: |
                body_lines=()
                body_lines+=("| Platform | Package type | File name | SHA256 checksum |")
                body_lines+=("| --- | --- | --- | --- |")
                for dir in *
                do
                    cd $dir
                    os=$(echo $RELEASE_META | jq -r --arg dir $dir '.[$dir].os')
                    portable_url=$(echo $RELEASE_META | jq -r --arg dir $dir '.[$dir].portable_url')
                    installer_url=$(echo $RELEASE_META | jq -r --arg dir $dir '.[$dir].installer_url')
                    
                    for file in *
                    do
                        checksum=$(sha256sum $file | cut -d ' ' -f 1)
                        if [[ "$file" == *"installer"* ]]
                        then
                            url=$installer_url
                            type="Installer"
                        else
                            url=$portable_url
                            type="Portable"
                        fi
                        
                        body_lines+=("| $os | $type | [$file]($url) | \`$checksum\` |")
                    done
                    
                    cd ..
                done                
                
                body=$(printf "%s\n" "${body_lines[@]}")
                $SCRIPTS/update_release_body.sh $RELEASE_ID "$TAG_NAME" "$body" >/dev/null