From a8e3f8d007b84c7a4d586c121955236e9d4d12a9 Mon Sep 17 00:00:00 2001 From: Thierry Marianne Date: Mon, 28 Jun 2021 20:01:56 +0200 Subject: [PATCH] Add scripts to build zip archive containing binaries for windows Remove travis configuration file Fix misc issues Add operating system name to the name of each built artifact Fix typo Fix name to artifact to be uploaded Move windows archive is to the root of the workspace --- .github/workflows/release.yml | 39 +++++++++++++ .travis.yml | 47 ---------------- .../github-actions/build-windows-package.sh | 18 ++++++ .../github-actions/release-linux-packages.sh | 4 +- .../github-actions/release-macos-package.sh | 4 +- .../github-actions/release-windows-package.sh | 55 +++++++++++++++++++ 6 files changed, 116 insertions(+), 51 deletions(-) delete mode 100644 .travis.yml create mode 100644 contrib/github-actions/build-windows-package.sh create mode 100644 contrib/github-actions/release-windows-package.sh diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index defadd25f9..8958ecda7c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -113,3 +113,42 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} RELEASE_NAME: ${{ env.RELEASE_NAME }} + + windows: + needs: release + + runs-on: ubuntu-latest + + steps: + + - name: Set env + run: echo "RELEASE_NAME=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + + - name: Install packages + run: sudo apt-get install rpm jq bash curl zip + + - name: Install Go + uses: actions/setup-go@v2 + with: + go-version: 1.16.x + + - run: go version + + - uses: actions/checkout@v2 + + - name: Build binaries + run: /bin/bash -c "source $GITHUB_WORKSPACE/contrib/github-actions/build-windows-package.sh" + env: + PKT_FAIL_DIRTY: 1 + RELEASE_NAME: ${{ env.RELEASE_NAME }} + + - uses: actions/upload-artifact@main + with: + path: | + ${{ github.workspace }}/${{ env.RELEASE_NAME }}-win.zip + + - name: Publish release + run: /bin/bash -c "source $GITHUB_WORKSPACE/contrib/github-actions/release-windows-package.sh" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + RELEASE_NAME: ${{ env.RELEASE_NAME }} \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index ab7cbae9e4..0000000000 --- a/.travis.yml +++ /dev/null @@ -1,47 +0,0 @@ -language: go -go: 1.15.3 -install: - - git config remote.origin.fetch +refs/heads/*:refs/remotes/origin/* - - git fetch --tags - - git fetch --all -git: - depth: false - autocrlf: input - symlinks: true -env: - - PKT_FAIL_DIRTY=1 -jobs: - include: - - os: linux - dist: bionic - addons: - apt: - packages: - - rpm - script: - - git diff - - git reset --hard - - ./do - - gem install --no-document fpm - - bash -x ./contrib/deb/build.sh - - bash -x ./contrib/rpm/build.sh - - os: osx - script: - - git diff - - git reset --hard - - ./do - - gem install --no-document fpm - - bash -x ./contrib/macos/build.sh -deploy: - provider: releases - api_key: - secure: NMxpJBSdsTzw/GptBg6Uzv6b5hoMjO9UkPChzu2ef6NZvX6BITNDxPvuTMiFGuGhIIMphkdpQMzp+PweoQxqQXmhEsTlbGMVS/14ce6+kit9n0y02uYeP5oodVFrw7l2f9wMCo2q59yGvFZxXvcnyXoPR9frCkNR/7QJPdbeKP2xgwOamXll3x+GRNZVQVYrlb86LqEF0WkHsckLQUkjcUpl3CAqH1otocdrb2E6Myafhisugidlz5Egwcmotj8PaJZgwpvSCZ6ccjW7RKT3ETBGiQRJtUEaGZmxJ5+2MZG8nr8bTuZTuNTUBZVV2BdRr5ZihM5khehhH4UhOpr76PmFT9WvnPIIMmC8LofhdInua/h/Ynwcok32+BSKBlKkIVITVIhSnRsuHHJnGB7vnWu3UU8hQoIrAX4D3+lX69f9QeXzWv+z6xN9JoCrEZfTQvWiE4jrz1V2uj6FHkmHC5k+LX454om/la9I9RZ4oOmiTjfG9oLPGsncoo34zcEPzbku4ojvMZLQ6pJ4JjfDO7qKQnQTXk4sDLNsnbf7fiow7yng3D6gfHgoX3sLcFRmH5kNDLcccEtSqqhzAEBTRJx5nmeCrKthzqy9YVyJHVkD1oVCDOf5cZmkLHUMNSXdIJYB06ZXeOr8aqfLp71O0/DinBLHgcGHqDQcdB4UcAk= - file_glob: true - file: - - "pktd-mac-*.pkg" - - "pktd-linux-*.rpm" - - "pktd-linux_*.deb" - on: - repo: pkt-cash/pktd - tags: true - cleanup: false diff --git a/contrib/github-actions/build-windows-package.sh b/contrib/github-actions/build-windows-package.sh new file mode 100644 index 0000000000..3843e420f6 --- /dev/null +++ b/contrib/github-actions/build-windows-package.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +function build() { + cd "${GITHUB_WORKSPACE}" || exit + + source ./do GOOS=windows GOARCH=amd64 + + mkdir ./bin/bin + + mv ./bin/*.exe ./bin/bin + + cd bin || exit + + zip -r "./${RELEASE_NAME}-win.zip" ./bin + + mv -v "./${RELEASE_NAME}-win.zip" "${GITHUB_WORKSPACE}"'/'"${RELEASE_NAME}"'-win.zip' +} +build \ No newline at end of file diff --git a/contrib/github-actions/release-linux-packages.sh b/contrib/github-actions/release-linux-packages.sh index 5a0c330f52..275265b1e3 100644 --- a/contrib/github-actions/release-linux-packages.sh +++ b/contrib/github-actions/release-linux-packages.sh @@ -42,14 +42,14 @@ function publish() { --data-binary @${binary} \ -H 'Content-Type: application/octet-stream' \ -H "Authorization: Bearer ${GITHUB_TOKEN}" \ - "${upload_url}?name=${release_name}${extension}" + "${upload_url}?name=${release_name}-linux${extension}" curl \ -X POST \ --data "$checksum" \ -H 'Content-Type: text/plain' \ -H "Authorization: Bearer ${GITHUB_TOKEN}" \ - "${upload_url}?name=${release_name}${extension}.sha256sum" + "${upload_url}?name=${release_name}-linux${extension}.sha256sum" } publish "${GITHUB_WORKSPACE}"'/'"${RELEASE_NAME}"'-linux-x86_64.rpm' '.rpm' diff --git a/contrib/github-actions/release-macos-package.sh b/contrib/github-actions/release-macos-package.sh index de11bf925f..49e05cc88f 100644 --- a/contrib/github-actions/release-macos-package.sh +++ b/contrib/github-actions/release-macos-package.sh @@ -41,14 +41,14 @@ function publish() { --data-binary @${binary} \ -H 'Content-Type: application/octet-stream' \ -H "Authorization: Bearer ${GITHUB_TOKEN}" \ - "${upload_url}?name=${release_name}${extension}" + "${upload_url}?name=${release_name}-macos${extension}" curl \ -X POST \ --data "$checksum" \ -H 'Content-Type: text/plain' \ -H "Authorization: Bearer ${GITHUB_TOKEN}" \ - "${upload_url}?name=${release_name}${extension}.sha256sum" + "${upload_url}?name=${release_name}-macos${extension}.sha256sum" } publish "${GITHUB_WORKSPACE}"'/'"${RELEASE_NAME}"'-mac.pkg' '.pkg' diff --git a/contrib/github-actions/release-windows-package.sh b/contrib/github-actions/release-windows-package.sh new file mode 100644 index 0000000000..cdbd0ebf49 --- /dev/null +++ b/contrib/github-actions/release-windows-package.sh @@ -0,0 +1,55 @@ +#!/bin/bash + +function publish() { + local archive + archive="${1}" + + local extension + extension="${2}" + + if [ ! -e "${archive}" ]; + then + echo 'Invalid archive ('"${archive}"')' + return 1 + fi + + local checksum + checksum="$(sha256sum "${archive}" | cut -d ' ' -f 1)" + + local base_url + base_url='https://api.github.com/repos/'"${GITHUB_REPOSITORY}" + + local upload_url + upload_url="$(curl \ + -H 'Content-Type: application/octet-stream' \ + -H "Authorization: Bearer ${GITHUB_TOKEN}" \ + "${base_url}"/releases 2>> /dev/null | \ + jq -r '.[] | .upload_url' | \ + head -n1)" + + upload_url=${upload_url/\{?name,label\}/} + + local release_name + release_name="$(curl \ + -H 'Content-Type: application/octet-stream' \ + -H "Authorization: Bearer ${GITHUB_TOKEN}" \ + "${base_url}"/releases 2>> /dev/null | \ + jq -r '.[] | .tag_name' | \ + head -n1)" + + curl \ + -X POST \ + --data-binary @${archive} \ + -H 'Content-Type: application/octet-stream' \ + -H "Authorization: Bearer ${GITHUB_TOKEN}" \ + "${upload_url}?name=${release_name}-windows${extension}" + + curl \ + -X POST \ + --data "$checksum" \ + -H 'Content-Type: text/plain' \ + -H "Authorization: Bearer ${GITHUB_TOKEN}" \ + "${upload_url}?name=${release_name}-windows${extension}.sha256sum" +} + +publish "${GITHUB_WORKSPACE}"'/'"${RELEASE_NAME}"'-win.zip' '.zip'