Skip to content

Commit 0b48d2f

Browse files
Merge pull request #21 from OpenAstroTech/feature/js/19-optimize-windows-ci-build-upload-artifact
GHA faster upload/download
2 parents 6020117 + 54fdbf4 commit 0b48d2f

1 file changed

Lines changed: 24 additions & 41 deletions

File tree

.github/workflows/build-and-release.yaml

Lines changed: 24 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,18 @@ jobs:
7676
- name: Remove smoke test artifacts
7777
run: |
7878
rm -rv ./dist/logs
79-
# Work around stupid issue that GHA can't store file permissions on artifacts
80-
- name: Store which files are executable
81-
run: pushd dist/ && find . -type f -executable -print > restore_executable_permissions.txt && popd
79+
rm -rv ./dist/OATFWGUI/__pycache__
80+
- name: Set artifact name
81+
run: echo "ARTIFACT_ZIP_NAME=OATFWGUI_${{ env.OATFWGUI_VERSION }}_${{ runner.os }}_${{ runner.arch }}" >> $GITHUB_ENV
82+
- name: Rename and Zip artifacts
83+
run: mv dist $ARTIFACT_ZIP_NAME && 7z a -tzip $ARTIFACT_ZIP_NAME.zip $ARTIFACT_ZIP_NAME/
84+
env:
85+
ARTIFACT_ZIP_NAME: ${{ env.ARTIFACT_ZIP_NAME }}
8286
- name: Upload artifact
8387
uses: actions/upload-artifact@v3
8488
with:
85-
name: OATFWGUI_${{ env.OATFWGUI_VERSION }}_${{ runner.os }}_${{ runner.arch }}
86-
path: dist/*
89+
name: ${{ env.ARTIFACT_ZIP_NAME }}
90+
path: ${{ env.ARTIFACT_ZIP_NAME }}.zip
8791

8892
build-virtualenv:
8993
runs-on: 'ubuntu-20.04'
@@ -125,16 +129,19 @@ jobs:
125129
run: |
126130
rm -rv ./dist/logs
127131
rm -rv ./dist/.venv_*
128-
# Work around stupid issue that GHA can't store file permissions on artifacts
129-
- name: Store which files are executable
130-
run: pushd dist/ && find . -type f -executable -print > restore_executable_permissions.txt && popd
131-
132+
rm -rv ./dist/OATFWGUI/__pycache__
133+
- name: Set artifact name
134+
run: echo "ARTIFACT_ZIP_NAME=OATFWGUI_${{ env.OATFWGUI_VERSION }}_${{ runner.os }}_${{ runner.arch }}" >> $GITHUB_ENV
135+
- name: Rename and Zip artifacts
136+
run: mv dist $ARTIFACT_ZIP_NAME && 7z a -tzip $ARTIFACT_ZIP_NAME.zip $ARTIFACT_ZIP_NAME/
137+
env:
138+
ARTIFACT_ZIP_NAME: ${{ env.ARTIFACT_ZIP_NAME }}
132139
- name: Upload artifact
133140
if: ${{ matrix.py_version }} == "3.10" # Only publish one artifact
134141
uses: actions/upload-artifact@v3
135142
with:
136-
name: OATFWGUI_${{ env.OATFWGUI_VERSION }}_${{ runner.os }}_${{ runner.arch }}
137-
path: dist/*
143+
name: ${{ env.ARTIFACT_ZIP_NAME }}
144+
path: ${{ env.ARTIFACT_ZIP_NAME }}.zip
138145

139146
publish-release:
140147
# only publish release on tags
@@ -150,41 +157,17 @@ jobs:
150157
uses: actions/download-artifact@v3
151158
with:
152159
path: artifacts
153-
- name: Restore executable permissions
154-
run: |
155-
set -e
156-
shopt -s nullglob
157-
PERM_FILE='restore_executable_permissions.txt'
158-
for dir in artifacts/*/; do
159-
echo "Entering $dir"
160-
pushd "$dir"
161-
if [ ! -f "$PERM_FILE" ]; then
162-
echo "Could not find permissions file ${PERM_FILE}!"
163-
continue
164-
fi
165-
while IFS= read -r f_path || [ -n "$f_path" ]; do
166-
echo "Restoring execution on $f_path"
167-
chmod +x "$f_path"
168-
done < "$PERM_FILE"
169-
rm -v "$PERM_FILE"
170-
popd
171-
done
172-
- name: Zip artifacts
160+
- name: Show artifact contents
173161
run: |
174-
set -e
175-
shopt -s nullglob
176-
pushd artifacts/
177-
for dir in ./*/; do
178-
out_zip="../$(basename $dir).zip"
179-
echo "Zipping $dir into $out_zip"
180-
zip -8 --recurse-paths "$out_zip" "$dir"
162+
tree .
163+
for zip_dist in artifacts/*/*.zip; do
164+
echo "$zip_dist contains:"
165+
zip -sf $zip_dist
181166
done
182-
popd
183167
- name: Publish GitHub release
184168
uses: softprops/action-gh-release@v1
185169
with:
186170
name: ${{ github.ref_name }}
187171
generate_release_notes: true
188172
fail_on_unmatched_files: true
189-
files: |
190-
*.zip
173+
files: artifacts/*/*.zip

0 commit comments

Comments
 (0)