Skip to content

Commit d8c86ea

Browse files
authoredMar 13, 2024
build: remove dependency on asset/ directory existence. (#51)
* build: remove dependency on asset/ directory existence. * docs: add comments explaining why we ignore cp errors
1 parent bbce9df commit d8c86ea

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed
 

Diff for: ‎.github/workflows/release.yaml

+5-4
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
- name: Prepare package
4343
run: |
4444
wasm-bindgen --no-typescript --out-name bevy_game --out-dir wasm --target web target/wasm32-unknown-unknown/release/${{ env.binary }}.wasm
45-
cp -r assets wasm/
45+
cp -r assets wasm/ || true # Try to copy, but ignore if it can't copy if source directory does not exist
4646
4747
- name: Package as a zip
4848
working-directory: ./wasm
@@ -91,7 +91,7 @@ jobs:
9191
run: |
9292
mkdir linux
9393
cp target/x86_64-unknown-linux-gnu/release/${{ env.binary }} linux/
94-
cp -r assets linux/
94+
cp -r assets linux/ || true # Try to copy, but ignore if it can't copy if source directory does not exist
9595
9696
- name: Package as a zip
9797
working-directory: ./linux
@@ -137,6 +137,7 @@ jobs:
137137
run: |
138138
mkdir windows
139139
cp target/x86_64-pc-windows-msvc/release/${{ env.binary }}.exe windows/
140+
mkdir assets -ea 0 # create the assets directory if it does not exist, it will get ignored in the zip if empty
140141
cp -r assets windows/
141142
142143
- name: Package as a zip
@@ -186,7 +187,7 @@ jobs:
186187
run: |
187188
mkdir -p ${{ env.binary }}.app/Contents/MacOS
188189
cp target/x86_64-apple-darwin/release/${{ env.binary }} ${{ env.binary }}.app/Contents/MacOS/
189-
cp -r assets ${{ env.binary }}.app/Contents/MacOS/
190+
cp -r assets ${{ env.binary }}.app/Contents/MacOS/ || true # Try to copy, but ignore if it can't copy if source directory does not exist
190191
hdiutil create -fs HFS+ -volname "${{ env.binary }}" -srcfolder ${{ env.binary }}.app ${{ env.binary }}-macOS-intel.dmg
191192
192193
- name: Upload binaries to artifacts
@@ -232,7 +233,7 @@ jobs:
232233
run: |
233234
mkdir -p ${{ env.binary }}.app/Contents/MacOS
234235
cp target/aarch64-apple-darwin/release/${{ env.binary }} ${{ env.binary }}.app/Contents/MacOS/
235-
cp -r assets ${{ env.binary }}.app/Contents/MacOS/
236+
cp -r assets ${{ env.binary }}.app/Contents/MacOS/ || true # Try to copy, but ignore if it can't copy if source directory does not exist
236237
hdiutil create -fs HFS+ -volname "${{ env.binary }}-macOS-apple-silicon" -srcfolder ${{ env.binary }}.app ${{ env.binary }}-macOS-apple-silicon.dmg
237238
238239
- name: Upload binaries to artifacts

Diff for: ‎README.md

+4-7
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ This workflow runs on every tag.
2929

3030
It will build:
3131
* For Linux and Windows, a .zip archive containing the executable and the `assets`.
32-
* For macOS, a dmg image with a .app containing the assets.
33-
* For wasm, a .zip archive with the wasm binary, the js bindings, an html file loading it, and the assets.
32+
* For macOS, a dmg image with a .app containing the `assets`.
33+
* For wasm, a .zip archive with the wasm binary, the js bindings, an html file loading it, and the `assets`.
3434

3535
If you don't want to target some of those platforms, you can remove the corresponding job from the file [release.yaml](./.github/workflows/release.yaml).
3636

@@ -67,11 +67,8 @@ If you would like to use the GitHub workflows included here for your own project
6767

6868
1. The release workflow relies on the `index.html` file under `/wasm` for web builds
6969
2. Make sure that the env variable `binary` ([release.yaml](.github/workflows/release.yaml#L10)) matches the name of your binary
70-
3. In case your project doesn't have an `assets` folder
71-
1. Either create one and put a `.gitkeep` file in it to be able to push it
72-
2. Or remove the `cp -r assets` statements in the build jobs
73-
4. Adapt the used toolchain if you are using nightly
74-
5. In your GitHub repo's settings, under `Actions -> General` make sure "Read and Write permissions" is selected under "Workflow permissions" near the bottom. This fixes the error `Error: Resource not accessible by integration`.
70+
3. Adapt the used toolchain if you are using nightly
71+
4. In your GitHub repo's settings, under `Actions -> General` make sure "Read and Write permissions" is selected under "Workflow permissions" near the bottom. This fixes the error `Error: Resource not accessible by integration`.
7572

7673

7774
### Publish on itch.io

0 commit comments

Comments
 (0)