Skip to content

Commit

Permalink
Add scripts to build and publish windows archive containing newly com…
Browse files Browse the repository at this point in the history
…piled binary on tag push

Replace rpm and deb packaging with statically compiled build
Revise step name
Install make package
Revise windows and linux builds
Restore action responsible for building linux binary
Install gcc-mingw-w64-x86-64 package required to build windows binary
Remove jemalloc feature when building windows binary
Add _amd64 suffix to linux binary
  • Loading branch information
thierrymarianne committed Jul 1, 2021
1 parent c492500 commit b3112bb
Show file tree
Hide file tree
Showing 8 changed files with 135 additions and 75 deletions.
70 changes: 53 additions & 17 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,41 +30,37 @@ jobs:
run: echo "RELEASE_NAME=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV

- name: Install packages
run: sudo apt-get install bash build-essential curl jq gcc git rpm rubygems
run: sudo apt-get install bash build-essential curl jq gcc git make musl-tools

- name: Set up Ruby 2.6
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6

- uses: actions/checkout@v2

- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: complete
toolchain: stable
target: x86_64-unknown-linux-musl

- name: Set up rust cache
uses: Swatinem/rust-cache@v1

- name: Set up Ruby 2.6
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6

- name: Install fpm
run: gem install --no-document fpm

- uses: actions/checkout@v2

- name: Build binaries
run: /bin/bash -c "source $GITHUB_WORKSPACE/contrib/github-actions/build-linux-packages.sh"
run: /bin/bash -c "source $GITHUB_WORKSPACE/contrib/github-actions/build-linux-binary.sh"
env:
PKT_FAIL_DIRTY: 1
RELEASE_NAME: ${{ env.RELEASE_NAME }}

- uses: actions/upload-artifact@main
with:
path: |
${{ github.workspace }}/${{ env.RELEASE_NAME }}-linux-x86_64.rpm
${{ github.workspace }}/${{ env.RELEASE_NAME }}-linux-amd64.deb
${{ github.workspace }}/${{ env.RELEASE_NAME }}
- name: Publish release
run: /bin/bash -c "source $GITHUB_WORKSPACE/contrib/github-actions/release-linux-packages.sh"
run: /bin/bash -c "source $GITHUB_WORKSPACE/contrib/github-actions/release-linux-binary.sh"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_NAME: ${{ env.RELEASE_NAME }}
Expand Down Expand Up @@ -104,7 +100,6 @@ jobs:
- name: Build binaries
run: /bin/bash -c "source $GITHUB_WORKSPACE/contrib/github-actions/build-macos-package.sh"
env:
PKT_FAIL_DIRTY: 1
RELEASE_NAME: ${{ env.RELEASE_NAME }}

- uses: actions/upload-artifact@main
Expand All @@ -117,3 +112,44 @@ 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 bash build-essential curl jq gcc gcc-mingw-w64-x86-64 git make zip

- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: complete
toolchain: stable
target: x86_64-pc-windows-gnu

- name: Set up rust cache
uses: Swatinem/rust-cache@v1

- uses: actions/checkout@v2

- name: Build binaries
run: /bin/bash -c "source $GITHUB_WORKSPACE/contrib/github-actions/build-windows-package.sh"
env:
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 }}
8 changes: 0 additions & 8 deletions contrib/deb/build.sh

This file was deleted.

12 changes: 12 additions & 0 deletions contrib/github-actions/build-linux-binary.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

function build() {
cd "${GITHUB_WORKSPACE}" || exit
cargo build --release --features jemalloc --target=x86_64-unknown-linux-musl

mkdir "${GITHUB_WORKSPACE}/bin"

cp "${GITHUB_WORKSPACE}/target/x86_64-unknown-linux-musl/release/packetcrypt" \
"${GITHUB_WORKSPACE}"'/'"${RELEASE_NAME}"
}
build
25 changes: 0 additions & 25 deletions contrib/github-actions/build-linux-packages.sh

This file was deleted.

13 changes: 13 additions & 0 deletions contrib/github-actions/build-windows-package.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

function build() {
cd "${GITHUB_WORKSPACE}" || exit
cargo build --release --target x86_64-pc-windows-gnu

mkdir ./bin

mv ./target/x86_64-pc-windows-gnu/release/packetcrypt.exe ./bin

zip -r "./${RELEASE_NAME}-win.zip" ./bin
}
build
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ function publish() {
local binary
binary="${1}"

local extension
extension="${2}"

if [ ! -e "${binary}" ];
then
echo 'Invalid binary ('"${binary}"')'
Expand Down Expand Up @@ -42,15 +39,14 @@ function publish() {
--data-binary @${binary} \
-H 'Content-Type: application/octet-stream' \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
"${upload_url}?name=${release_name}-linux${extension}"
"${upload_url}?name=${release_name}-linux_amd64"

curl \
-X POST \
--data "$checksum" \
-H 'Content-Type: text/plain' \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
"${upload_url}?name=${release_name}-linux${extension}.sha256sum"
"${upload_url}?name=${release_name}-linux_amd64.sha256sum"
}

publish "${GITHUB_WORKSPACE}"'/'"${RELEASE_NAME}"'-linux-x86_64.rpm' '.rpm'
publish "${GITHUB_WORKSPACE}"'/'"${RELEASE_NAME}"'-linux-amd64.deb' '.deb'
publish "${GITHUB_WORKSPACE}"'/'"${RELEASE_NAME}"
54 changes: 54 additions & 0 deletions contrib/github-actions/release-windows-package.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@

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'
18 changes: 0 additions & 18 deletions contrib/rpm/build.sh

This file was deleted.

0 comments on commit b3112bb

Please sign in to comment.