Skip to content

Replace deprecated zip-extract with zip crate #950

Replace deprecated zip-extract with zip crate

Replace deprecated zip-extract with zip crate #950

Workflow file for this run

on:
workflow_dispatch:
pull_request:
types: [ opened, synchronize, closed ]
branches: [ main ]
concurrency:
group: "${{ github.workflow }}-${{ github.head_ref || github.ref }}-${{ github.event_name }}"
cancel-in-progress: true
name: gg.cmd
jobs:
version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- name: Generate version
if: github.event.pull_request.merged == true
id: buildnumber
uses: einaregilsson/build-number@v3
with:
token: ${{ github.token }}
- name: Set version
id: version
run: |
if [ "${{github.event.pull_request.merged}}" == "true" ]; then
echo "version=${{ steps.buildnumber.outputs.build_number }}" >> $GITHUB_OUTPUT
else
echo "version=dev" >> $GITHUB_OUTPUT
fi
stage4-OS:
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
- os: windows-latest
target: x86_64-pc-windows-msvc
- os: macos-14
target: aarch64-apple-darwin
- os: ubuntu-22.04-arm
target: aarch64-unknown-linux-musl
- os: macos-15-intel
target: x86_64-apple-darwin
runs-on: ${{ matrix.os }}
needs: version
steps:
- uses: actions/checkout@v6
- name: Prepare build
shell: bash
run: |
if [[ "${{ matrix.os }}" == *"ubuntu"* ]]
then
sudo apt-get -y update
sudo apt-get -y install musl-dev musl-tools
export CC=musl-gcc
fi
rustup update
rustup target add ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
with:
workspaces: "stage42"
- name: Build
shell: bash
run: |
mkdir -p stage42
mv src/stage4/* stage42
rm -rf src
cd stage42
export VERSION=${{needs.version.outputs.version}}
cargo test
cargo build --release --target=${{ matrix.target }}
find . -type f -name stage4.exe -exec cp {} ../stage4 \;
find . -type f -name stage4 -exec cp {} ../stage4 \;
strip ../stage4
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: stage4_${{ matrix.target }}
path: stage4
hash:
needs: [ stage4-OS ]
runs-on: ubuntu-latest
outputs:
has_secret: ${{ steps.check.outputs.has_secret }}
steps:
- name: Check for secret
id: check
run: echo "has_secret=${{ secrets.ConnectionString != '' }}" >> $GITHUB_OUTPUT
- name: Download stage4 hash
uses: actions/download-artifact@v8
- name: Rename to hash
shell: bash
run: |
mkdir hash
mkdir out
touch hashes
for dir in stage4_*
do
file=$dir/stage4
hash=$(sha512sum $file | awk '{ print $1 }')
cp $file out/$hash
echo $hash > hash/hash_$dir
echo $dir=$hash >> hashes
done
- name: Upload hash artifact
uses: actions/upload-artifact@v7
with:
name: hash
path: hash
- name: Upload hash artifact
uses: actions/upload-artifact@v7
with:
name: hashes
path: hashes
- uses: LanceMcCarthy/Action-AzureBlobUpload@v3
if: steps.check.outputs.has_secret == 'true'
with:
connection_string: ${{ secrets.ConnectionString }}
container_name: $web
source_folder: out
stage3-OS:
needs: hash
strategy:
matrix:
include:
- os: ubuntu-22.04
target: x86_64-unknown-linux-gnu
stage4: x86_64-unknown-linux-musl
- os: ubuntu-22.04
target: x86_64-unknown-linux-musl
stage4: x86_64-unknown-linux-musl
- os: ubuntu-22.04-arm
target: aarch64-unknown-linux-musl
stage4: aarch64-unknown-linux-musl
- os: ubuntu-22.04-arm
target: aarch64-unknown-linux-gnu
stage4: aarch64-unknown-linux-musl
- os: macos-14
target: aarch64-apple-darwin
stage4: aarch64-apple-darwin
- os: macos-15-intel
target: x86_64-apple-darwin
stage4: x86_64-apple-darwin
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v6
- name: Download stage4 hash
uses: actions/download-artifact@v8
with:
name: hash
path: hash
- name: Hash
# ENV -> CMAKE -> Code very hard. This very easy
shell: bash
run: |
hash=$(cat hash/hash_stage4_${{ matrix.stage4 }})
echo "now hash is $hash"
echo "const char *hash = \"$hash\";" > src/stage3/const.h
- name: Makus
shell: bash
run: |
set -x
cd src/stage3
if [[ "${{ matrix.target }}" == *"musl"* ]]
then
sudo apt-get -y update
sudo apt-get -y install musl-dev musl-tools
export CC=musl-gcc
fi
cmake -B build -DCMAKE_EXE_LINKER_FLAGS='-Os' -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release
find . -type f \( -name stage3 -o -name stage3.exe \) -exec cp {} ../../stage3_${{ matrix.target }} \;
strip ../../stage3_${{ matrix.target }}
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: stage3_${{ matrix.target }}
path: stage3_${{ matrix.target }}
stage1:
needs: [ version, stage3-OS ]
runs-on: ubuntu-latest
steps:
- name: Source
uses: actions/checkout@v6
- name: Download stage3 / stage4
uses: actions/download-artifact@v8
- name: gg.cmd
run: |
sudo apt-get install dos2unix
mv src/stage1 _stage1
mv src/stage2 _stage2
mv src/stage3 _stage3
VERSION=${{needs.version.outputs.version}}
rm -rf gg-$VERSION
mkdir -p gg-$VERSION
rm -rf src
for dir in stage3*; do
for file in "$dir"/*; do
cp "$file" gg-$VERSION/
done
done
# Prevent wine from trying to run (if installed on users PC)
# mv .cache/gg/stage3_x86_64-pc-windows-msvc .cache/gg/stage3_zz_x86_64-pc-windows-msvc
sed -i "s/VERVER/$VERSION/g" _stage2/stage2.*
cp _stage2/stage2.sh gg-$VERSION/
cp _stage2/stage2.ps1 gg-$VERSION/
cp hashes/hashes gg-$VERSION/
chmod +x gg-$VERSION/stage2.sh
tar -zpvcf gg.tgz gg-$VERSION
sed -i "s/VERVER/$VERSION/g" _stage1/stage1.*
unix2dos _stage1/stage1.bat
cat _stage1/stage1.bat _stage1/stage1.sh > 1
a=$(du -cb 1 | tail -n 1 | awk '{print $1}')
b=a
((b++))
sed -i "s/AAAA/$a/" 1;
sed -i "s/BBBB/$b/" 1;
cat 1 gg.tgz > gg.cmd
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: gg.cmd
path: gg.cmd
test-OS1:
needs: [ stage1, hash ]
strategy:
matrix:
os: [ ubuntu-22.04, windows-2022 ]
cmd: [ "node -v", "java -version", "gradle -version", "openapi version", "run:java@14 java -version", "deno -V", "caddy -v", "jbang --version", "just -V", "run:java@21-azul java -version", "run:java@21-tem java -version", "run:java@17-tem java -version", "fortio version", "fastlane --version", "gh/mozilla/sccache -V" ]
include:
- os: ubuntu-22.04
stage4_target: x86_64-unknown-linux-musl
- os: windows-2022
stage4_target: x86_64-pc-windows-msvc
runs-on: ${{ matrix.os }}
steps:
- name: Download gg
uses: actions/download-artifact@v8
with:
name: gg.cmd
- name: Download stage4
if: needs.hash.outputs.has_secret != 'true'
uses: actions/download-artifact@v8
with:
name: stage4_${{ matrix.stage4_target }}
- name: Pre-populate cache with stage4
if: needs.hash.outputs.has_secret != 'true'
shell: bash
run: |
mkdir -p "$HOME/.cache/gg/gg-dev"
SYSTEM="${{ matrix.stage4_target }}"
if getconf GNU_LIBC_VERSION >/dev/null 2>&1; then SYSTEM="${SYSTEM/musl/gnu}"; fi
echo "$SYSTEM" > "$HOME/.cache/gg/gg-dev/system"
if [[ "${{ runner.os }}" == "Windows" ]]; then
cp stage4 "$HOME/.cache/gg/gg-dev/stage4.exe"
else
cp stage4 "$HOME/.cache/gg/gg-dev/stage4"
chmod +x "$HOME/.cache/gg/gg-dev/stage4"
fi
- name: Run!
shell: bash
run: |
set -x
sh gg.cmd -v ${{ matrix.cmd }}
echo "Nice, let's try again"
sh gg.cmd -v ${{ matrix.cmd }}
# Not all tools work on all OSes :/
test-OS2:
needs: [ stage1, hash ]
strategy:
matrix:
os: [ macos-14, macos-15-intel ]
cmd: [ "node -v", "java -version", "gradle -version", "openapi version", "deno -V", "jbang --version", "gh/cli/cli version", "gh version", "just -V", "run:java@21-azul java -version", "run:java@21-tem java -version", "run:java@17-tem java -version", "fastlane --version" ]
include:
- os: macos-14
stage4_target: aarch64-apple-darwin
- os: macos-15-intel
stage4_target: x86_64-apple-darwin
runs-on: ${{ matrix.os }}
steps:
- name: Download gg
uses: actions/download-artifact@v8
with:
name: gg.cmd
- name: Download stage4
if: needs.hash.outputs.has_secret != 'true'
uses: actions/download-artifact@v8
with:
name: stage4_${{ matrix.stage4_target }}
- name: Pre-populate cache with stage4
if: needs.hash.outputs.has_secret != 'true'
shell: bash
run: |
mkdir -p "$HOME/.cache/gg/gg-dev"
SYSTEM="${{ matrix.stage4_target }}"
if getconf GNU_LIBC_VERSION >/dev/null 2>&1; then SYSTEM="${SYSTEM/musl/gnu}"; fi
echo "$SYSTEM" > "$HOME/.cache/gg/gg-dev/system"
cp stage4 "$HOME/.cache/gg/gg-dev/stage4"
chmod +x "$HOME/.cache/gg/gg-dev/stage4"
- name: Run!
shell: bash
run: |
set -x
sh gg.cmd -v ${{ matrix.cmd }}
echo "Nice, let's try again"
sh gg.cmd -v ${{ matrix.cmd }}
test-OS3:
needs: [ stage1, hash ]
strategy:
matrix:
os: [ ubuntu-22.04-arm, macos-14, macos-15-intel ]
cmd: [ "node -v", "java -version", "gradle -version", "openapi version", "deno -V", "jbang --version", "just -V", "run:java@21-azul java -version", "run:java@21-tem java -version", "run:java@17-tem java -version", "fastlane --version" ]
include:
- os: ubuntu-22.04-arm
stage4_target: aarch64-unknown-linux-musl
- os: macos-14
stage4_target: aarch64-apple-darwin
- os: macos-15-intel
stage4_target: x86_64-apple-darwin
runs-on: ${{ matrix.os }}
steps:
- name: Download gg
uses: actions/download-artifact@v8
with:
name: gg.cmd
- name: Download stage4
if: needs.hash.outputs.has_secret != 'true'
uses: actions/download-artifact@v8
with:
name: stage4_${{ matrix.stage4_target }}
- name: Pre-populate cache with stage4
if: needs.hash.outputs.has_secret != 'true'
shell: bash
run: |
mkdir -p "$HOME/.cache/gg/gg-dev"
SYSTEM="${{ matrix.stage4_target }}"
if getconf GNU_LIBC_VERSION >/dev/null 2>&1; then SYSTEM="${SYSTEM/musl/gnu}"; fi
echo "$SYSTEM" > "$HOME/.cache/gg/gg-dev/system"
cp stage4 "$HOME/.cache/gg/gg-dev/stage4"
chmod +x "$HOME/.cache/gg/gg-dev/stage4"
- name: Run!
shell: bash
run: |
set -x
sh gg.cmd -v ${{ matrix.cmd }}
echo "Nice, let's try again"
sh gg.cmd -v ${{ matrix.cmd }}
test-batch:
needs: [ stage1, hash ]
strategy:
matrix:
os: [ windows-2022 ]
cmd: [ "node -v", "java -version", "gradle -version", "openapi version", "run:java@14 java -version", "deno -V", "caddy -v", "jbang --version", "gh/cli/cli version", "gh version", "just -V", "run:java@21-azul java -version", "run:java@21-tem java -version", "run:java@17-tem java -version", "fortio version", "fastlane --version", "gh/mozilla/sccache -V" ]
runs-on: ${{ matrix.os }}
steps:
- name: Download gg
uses: actions/download-artifact@v8
with:
name: gg.cmd
- name: Download stage4
if: needs.hash.outputs.has_secret != 'true'
uses: actions/download-artifact@v8
with:
name: stage4_x86_64-pc-windows-msvc
- name: Pre-populate cache with stage4
if: needs.hash.outputs.has_secret != 'true'
shell: bash
run: |
mkdir -p "$USERPROFILE/.cache/gg/gg-dev"
echo "x86_64-pc-windows-msvc" > "$USERPROFILE/.cache/gg/gg-dev/system"
cp stage4 "$USERPROFILE/.cache/gg/gg-dev/stage4.exe"
- name: Run!
shell: cmd
run: |
.\gg.cmd -v ${{ matrix.cmd }}
echo "Nice, let's try again"
.\gg.cmd -v ${{ matrix.cmd }}
- name: Test version flag
shell: cmd
run: |
.\gg.cmd -V
echo Exit code was %errorlevel%
test-container:
needs: [ stage1, hash ]
strategy:
matrix:
container: [ ubuntu, debian, alpine, archlinux ]
cmd: [ "node@14 -v", "java -version", "gradle -version", "openapi version", "run:java@14 java -version", "run:java@21-azul java -version", "run:java@21-tem java -version", "run:java@17-tem java -version", "just -V", "fortio version", "gh/mozilla/sccache -V" ]
runs-on: ubuntu-latest
container: ${{ matrix.container }}
steps:
- name: Download gg
uses: actions/download-artifact@v8
with:
name: gg.cmd
- name: Download stage4
if: needs.hash.outputs.has_secret != 'true'
uses: actions/download-artifact@v8
with:
name: stage4_x86_64-unknown-linux-musl
- name: Pre-populate cache with stage4
if: needs.hash.outputs.has_secret != 'true'
run: |
mkdir -p "$HOME/.cache/gg/gg-dev"
SYSTEM="x86_64-unknown-linux-musl"
if getconf GNU_LIBC_VERSION >/dev/null 2>&1; then SYSTEM=$(echo "$SYSTEM" | sed 's/musl/gnu/'); fi
echo "$SYSTEM" > "$HOME/.cache/gg/gg-dev/system"
cp stage4 "$HOME/.cache/gg/gg-dev/stage4"
chmod +x "$HOME/.cache/gg/gg-dev/stage4"
- name: Run!
run: |
set -x
# This is required for nodejs to run - not gg.cmd!
if [ "${{ matrix.container }}" == "alpine" ]; then
apk add libstdc++
fi
sh gg.cmd -v ${{ matrix.cmd }}
echo "Nice, let's try again"
sh gg.cmd -v ${{ matrix.cmd }}
# GitHub Actions hate me :/
gatekeeper:
needs: [ test-OS1, test-OS2, test-OS3, test-batch, test-container ]
runs-on: ubuntu-latest
if: always()
steps:
- name: Fail if any test job failed or was skipped
run: |
echo "Checking test job results..."
FAILED=0
echo "test-OS1: ${{ needs.test-OS1.result }}"
if [ "${{ needs.test-OS1.result }}" != "success" ]; then FAILED=1; fi
echo "test-OS2: ${{ needs.test-OS2.result }}"
if [ "${{ needs.test-OS2.result }}" != "success" ]; then FAILED=1; fi
echo "test-OS3: ${{ needs.test-OS3.result }}"
if [ "${{ needs.test-OS3.result }}" != "success" ]; then FAILED=1; fi
echo "test-batch: ${{ needs.test-batch.result }}"
if [ "${{ needs.test-batch.result }}" != "success" ]; then FAILED=1; fi
echo "test-container: ${{ needs.test-container.result }}"
if [ "${{ needs.test-container.result }}" != "success" ]; then FAILED=1; fi
if [ $FAILED -eq 1 ]; then
echo "::error::One or more test jobs failed or were skipped"
exit 1
fi
echo "All test jobs passed successfully"
release:
name: Release!
needs: [ version, gatekeeper ]
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true
steps:
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
tag_name: ${{ needs.version.outputs.version }}
release_name: ${{ needs.version.outputs.version }}
body: ${{ github.event.pull_request.body }}
- name: Download gg
uses: actions/download-artifact@v8
with:
name: gg.cmd
- name: Prepare upload
shell: bash
run: |
set -x
mkdir to_blob
cp gg.cmd to_blob
- uses: LanceMcCarthy/Action-AzureBlobUpload@v3
with:
connection_string: ${{ secrets.ConnectionString }}
container_name: $web
source_folder: to_blob
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token}}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./gg.cmd
asset_name: gg.cmd
asset_content_type: text/x-shellscript