diff --git a/.github/workflows/build-tcpdump.yml b/.github/workflows/build-tcpdump.yml index 1990ee9..b6a0b47 100644 --- a/.github/workflows/build-tcpdump.yml +++ b/.github/workflows/build-tcpdump.yml @@ -6,6 +6,8 @@ jobs: name: Build tcpdump x86 runs-on: ubuntu-latest container: muslcc/x86_64:i686-linux-musl + outputs: + version: ${{ steps.build_tcpdump.outputs.PACKAGED_VERSION }} steps: - name: Checkout uses: actions/checkout@v2 @@ -85,3 +87,35 @@ jobs: with: name: ${{ steps.build_tcpdump.outputs.PACKAGED_NAME }} path: ${{ steps.build_tcpdump.outputs.PACKAGED_NAME_PATH }} + + create-release: + name: Create tcpdump Release + runs-on: ubuntu-latest + needs: [build-x86, build-x86_64, build-armhf, build-aarch64] + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Prepare Environment + run: mkdir /tmp/releases + + - name: Download Artifacts + uses: actions/download-artifact@v2 + with: + path: /tmp/releases + + - name: List Artifacts + run: ls -laR /tmp/releases + + - name: Tag Release + run: | + git tag "tcpdump-v${{ needs.build-x86.outputs.version }}" + git push origin "tcpdump-v${{ needs.build-x86.outputs.version }}" + + - name: Create Release + uses: ncipollo/release-action@v1 + with: + name: tcpdump-v{{ needs.build-x86.outputs.version }} + tag: tcpdump-v${{ needs.build-x86.outputs.version }} + artifacts: "/tmp/releases/*/*" + token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/build/targets/build_tcpdump.sh b/build/targets/build_tcpdump.sh index 730954f..66b1bf9 100755 --- a/build/targets/build_tcpdump.sh +++ b/build/targets/build_tcpdump.sh @@ -1,12 +1,16 @@ #!/bin/bash -set -e -set -x -set -o pipefail +if [ -z "$GITHUB_WORKSPACE" ];then + echo "GITHUB_WORKSPACE environemnt variable not set!" + exit 1 +fi if [ "$#" -ne 1 ];then echo "Usage: ${0} [x86|x86_64|armhf|aarch64]" echo "Example: ${0} x86_64" exit 1 fi +set -e +set -o pipefail +set -x source $GITHUB_WORKSPACE/build/lib.sh init_lib "$1" @@ -31,11 +35,13 @@ main() { build_tcpdump local version version=$(get_version "${BUILD_DIRECTORY}/tcpdump/tcpdump --version 2>&1 | head -n1 | awk '{print \$3}'") + version_number=$(echo "$version" | cut -d"-" -f2) cp "${BUILD_DIRECTORY}/tcpdump/tcpdump" "${OUTPUT_DIRECTORY}/tcpdump" echo "[+] Finished building tcpdump ${CURRENT_ARCH}" echo ::set-output name=PACKAGED_NAME::"tcpdump${version}" echo ::set-output name=PACKAGED_NAME_PATH::"${OUTPUT_DIRECTORY}/*" + echo ::set-output name=PACKAGED_VERSION::"${version_number}" } main