Skip to content

Commit

Permalink
testing failure
Browse files Browse the repository at this point in the history
  • Loading branch information
Matte22 committed Feb 28, 2024
1 parent 7bedac2 commit 91638df
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 19 deletions.
34 changes: 20 additions & 14 deletions .github/workflows/build-binary-artifacts.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
# Modify build script

# attempt to sign the artifacts after they are built in the workflow
# if the signings fails then emit a warning and still upload only the binaries but exit with a non-zero status code
# if the signing is successful then import the public key and verify the signatures
# if the verification fails then emit a warning and exit with a non-zero status code
# if the verification is successful then emit a success message and upload the singing file and the signed artifacts

#signing_key="[email protected]"
#[[ $1 == "--sign" ]] && gpg --default-key $signing_key --armor --detach-sig $windows_archive
#[[ $1 == "--sign" ]] && gpg --default-key $signing_key --armor --detach-sig $linux_archive

name: Build Binary Artifacts
on:
workflow_dispatch:
push:
branches:
- main
paths:
- 'lib/**'
- 'index.js'
- 'build.sh'
- '.github/workflows/build-binary-artifacts.yml'
- "lib/**"
- "index.js"
- "build.sh"
- ".github/workflows/build-binary-artifacts.yml"
jobs:
build-binary-artifacts-and-sign:
name: Build binary artifacts, sign, export
Expand All @@ -30,10 +42,9 @@ jobs:
with:
gpg_private_key: ${{ secrets.WATCHER_PRIVATE_KEY }}

- name: run build script and sign
id: run_build_script_and_sign
run: ./build.sh --sign
continue-on-error: false
- name: run build script
id: run_build_script
run: ./build.sh

- name: Upload Artifacts
uses: actions/upload-artifact@v3
Expand All @@ -45,17 +56,14 @@ jobs:

- name: Import GPG Public Key
id: import_gpg_public
if: steps.run_build_script_and_sign.outcome == 'success'
run: gpg --import ./nuwcdivnpt-bot.gpg.asc

- name: Get version from package.json
id: package_version
if: steps.run_build_script_and_sign.outcome == 'success'
run: echo "PACKAGE_VERSION=$(jq -r '.version' package.json)" >> $GITHUB_ENV

- name: Verify Signatures
id: verify_signatures
if: steps.run_build_script_and_sign.outcome == 'success'
working-directory: ./dist
run: |
if ! gpg --verify stigman-watcher-linux-${{ env.PACKAGE_VERSION }}.tar.gz.asc stigman-watcher-linux-${{ env.PACKAGE_VERSION }}.tar.gz; then
Expand All @@ -64,5 +72,3 @@ jobs:
if ! gpg --verify stigman-watcher-win-${{ env.PACKAGE_VERSION }}.zip.asc stigman-watcher-win-${{ env.PACKAGE_VERSION }}.zip; then
echo "::warning ::Signature verification for Windows failed"
fi

24 changes: 19 additions & 5 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@
# - tar
# - gpg, if you wish to produce detached signatures

signing_key="[email protected]"
check_exit_status() {
if [[ $? -eq 0 ]]; then
echo "[BUILD_TASK] $1 succeeded"
else
echo "[BUILD_TASK] $1 failed"
exit $2
fi
}

bin_dir=./bin
dist_dir=./dist
Expand All @@ -28,25 +35,32 @@ printf "[BUILD_TASK] Fetching node_modules\n"
rm -rf ./node_modules
npm ci

# bundle
npx esbuild index.js --bundle --platform=node --outfile=bundle.js
# Bundle
printf "[BUILD_TASK] Bundling\n"
npx esbuild index.js --bunle --platform=node --outfile=bundle.js
check_exit_status "Bundling" 1

# version=$(git describe --tags | sed 's/\(.*\)-.*/\1/')
#get version from package.json
version=$(jq -r .version package.json)
check_exit_status "Getting Version" 5
printf "\n[BUILD_TASK] Using version string: $version\n"

# Make binaries
printf "\n[BUILD_TASK] Building binaries in $bin_dir\n"
pkg -C gzip --public --public-packages=* --no-bytecode pkg.config.json
check_exit_status "Building Binaries" 2

# Windows archive
windows_archive=$dist_dir/stigman-watcher-win-$version.zip
printf "\n[BUILD_TASK] Creating $windows_archive\n"
zip --junk-paths $windows_archive ./dotenv-example $bin_dir/stigman-watcher-win.exe
[[ $1 == "--sign" ]] && gpg --default-key $signing_key --armor --detach-sig $windows_archive
check_exit_status "Zipping Windows Archive" 3

# Linux archive
linux_archive=$dist_dir/stigman-watcher-linux-$version.tar.gz
printf "\n[BUILD_TASK] Creating $linux_archive\n"
tar -czvf $linux_archive --xform='s|^|stigman-watcher/|S' -C . dotenv-example -C $bin_dir stigman-watcher-linuxstatic
[[ $1 == "--sign" ]] && gpg --default-key $signing_key --armor --detach-sig $linux_archive
check_exit_status "Tarring linux Archive" 4

printf "\n[BUILD_TASK] Done\n"

0 comments on commit 91638df

Please sign in to comment.