diff --git a/.github/workflows/build-openssh.yml b/.github/workflows/build-openssh.yml index 45403dd..4a120e8 100644 --- a/.github/workflows/build-openssh.yml +++ b/.github/workflows/build-openssh.yml @@ -6,6 +6,8 @@ jobs: name: Build OpenSSH x86 runs-on: ubuntu-latest container: muslcc/x86_64:i686-linux-musl + outputs: + version: ${{ steps.build_openssh.outputs.PACKAGED_VERSION }} steps: - name: Checkout uses: actions/checkout@v2 @@ -84,4 +86,44 @@ jobs: uses: actions/upload-artifact@v2 with: name: ${{ steps.build_openssh.outputs.PACKAGED_NAME }} - path: ${{ steps.build_openssh.outputs.PACKAGED_NAME_PATH }} \ No newline at end of file + path: ${{ steps.build_openssh.outputs.PACKAGED_NAME_PATH }} + + create-release: + name: Create OpenSSH 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 + id: tag_release + run: | + set +e + if [ $(git tag "openssh-v${{ needs.build-x86.outputs.version }}") ];then + git push origin "openssh-v${{ needs.build-x86.outputs.version }}" + echo ::set-output name=NEW_RELEASE::"true" + else + echo "Tag for version ${{ needs.build-x86.outputs.version }} already exists. Skipping release creation." + echo ::set-output name=NEW_RELEASE::"false" + fi + + - name: Create Release + uses: ncipollo/release-action@v1 + if: ${{ steps.tag_release.outputs.NEW_RELEASE == 'true' }} + with: + name: openssh-v${{ needs.build-x86.outputs.version }} + tag: openssh-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_openssh.sh b/build/targets/build_openssh.sh index 33a6c1c..15d5093 100755 --- a/build/targets/build_openssh.sh +++ b/build/targets/build_openssh.sh @@ -43,6 +43,7 @@ main() { exit 1 fi OPENSSH_VERSION=$(get_version "${BUILD_DIRECTORY}/openssh-portable/ssh -V 2>&1 | awk '{print \$1}' | sed 's/,//g'") + version_number=$(echo "$OPENSSH_VERSION" | cut -d"_" -f2) cp "${BUILD_DIRECTORY}/openssh-portable/ssh" "${OUTPUT_DIRECTORY}/ssh${OPENSSH_VERSION}" cp "${BUILD_DIRECTORY}/openssh-portable/sshd" "${OUTPUT_DIRECTORY}/sshd${OPENSSH_VERSION}" echo "[+] Finished building OpenSSH ${CURRENT_ARCH}" @@ -50,6 +51,7 @@ main() { OPENSSH_VERSION=$(echo $OPENSSH_VERSION | sed 's/-//') echo ::set-output name=PACKAGED_NAME::"${OPENSSH_VERSION}" echo ::set-output name=PACKAGED_NAME_PATH::"/output/*" + echo ::set-output name=PACKAGED_VERSION::"${version_number}" } main