Skip to content

Commit

Permalink
Merge pull request #5 from Na-x4/release/v0.1.0
Browse files Browse the repository at this point in the history
Release v0.1.0
  • Loading branch information
Na-x4 authored Jan 18, 2022
2 parents 5e5c0e3 + acf8988 commit a030962
Show file tree
Hide file tree
Showing 4 changed files with 219 additions and 0 deletions.
120 changes: 120 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
on:
push:
branches:
- master

name: Release

jobs:
release:
name: Release
runs-on: ubuntu-latest
env:
CARGO_TERM_COLOR: always
cross-version: 0.2.1
cross-docker-image: rustembedded/cross:i686-pc-windows-gnu
outputs:
version: ${{ steps.version.outputs.CARGO_PKG_VERSION }}

steps:
- uses: actions/checkout@v2
- run: ./extract-aqtk.sh

- uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: i686-pc-windows-gnu
- name: Cache Cross
id: cache-cross
uses: actions/cache@v2
with:
path: ~/cross
key: ${{ runner.os }}-cross-${{ env.cross-version }}-${{ env.cross-docker-image }}
- name: Install Cross
if: steps.cache-cross.outputs.cache-hit != 'true'
run: |
mkdir ~/cross \
&& cargo install --version=${{ env.cross-version }} cross \
&& cp ~/.cargo/bin/cross ~/cross/ \
&& docker pull ${{ env.cross-docker-image }} \
&& docker save -o ~/cross/image.tar ${{ env.cross-docker-image }} \
- name: Use Cached Cross
if: steps.cache-cross.outputs.cache-hit == 'true'
run: |
cp ~/cross/cross ~/.cargo/bin/ \
&& docker load -i ~/cross/image.tar
- name: Build
run: cross build --color=always --target i686-pc-windows-gnu --release

- name: Get version
id: version
run: |
cargo metadata --format-version=1 --no-deps \
| jq -r '"::set-output name=CARGO_PKG_VERSION::" + .packages[].version'
- name: Package
run: |
mkdir release && cd release \
&& mv ../target/i686-pc-windows-gnu/release/aquestalk-proxy.exe ./aquestalk-proxy.exe \
&& mv ../aquestalk ./aquestalk \
&& cp ../README.md ./ \
&& cp ../COPYING ./ \
&& zip -r ../aquestalk-proxy_v${{ steps.version.outputs.CARGO_PKG_VERSION }}.zip *
- name: Release
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ steps.version.outputs.CARGO_PKG_VERSION }}
fail_on_unmatched_files: true
generate_release_notes: true
files: |
aquestalk-proxy_v${{ steps.version.outputs.CARGO_PKG_VERSION }}.zip
docker:
name: Push to Docker Hub
needs: release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
id: meta
with:
images: nax4/aquestalk-proxy
tags: |
type=semver,pattern={{ version }},value=${{ needs.release.outputs.version }}
type=raw,value=latest,enable=${{ endsWith(github.ref, github.event.repository.default_branch) }}
- uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
file: Dockerfile.release
platforms: linux/386
secrets: |
GITHUB_API_TOKEN=${{ secrets.GITHUB_TOKEN }}
build-args: |
VERSION=${{ needs.release.outputs.version }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max

- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
2 changes: 2 additions & 0 deletions Cross.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[target.i686-pc-windows-gnu]
image = "rustembedded/cross:i686-pc-windows-gnu"
53 changes: 53 additions & 0 deletions Dockerfile.release
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# syntax=docker/dockerfile:1.2
FROM debian as wine

ENV WINEDEBUG=-all

RUN INSTALL_DEPS=' \
ca-certificates \
curl \
gnupg2 \
' \
&& export DEBIAN_FRONTEND=noninteractive \
&& apt-get update \
&& apt-get install --no-install-recommends -y $INSTALL_DEPS \
gosu \
tini \
&& curl https://dl.winehq.org/wine-builds/winehq.key -sSf | gpg --dearmor > /usr/share/keyrings/winehq.gpg \
&& . /etc/os-release \
&& echo "deb [signed-by=/usr/share/keyrings/winehq.gpg] https://dl.winehq.org/wine-builds/debian/ $VERSION_CODENAME main" > /etc/apt/sources.list.d/wine-builds.list \
&& apt-get update \
&& apt-get install --no-install-recommends -y \
winehq-stable \
&& apt-get purge -y --auto-remove $INSTALL_DEPS \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& useradd -m user \
&& gosu user wine cmd.exe /c echo. > /dev/null 2>&1

FROM debian as downloader

RUN export DEBIAN_FRONTEND=noninteractive \
&& apt-get update \
&& apt-get install --no-install-recommends -y \
ca-certificates \
curl \
jq \
unzip \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

ARG VERSION
COPY /scripts/download.sh ./
RUN --mount=type=secret,id=GITHUB_API_TOKEN \
GITHUB_API_TOKEN=$(cat /run/secrets/GITHUB_API_TOKEN 2>/dev/null || echo) \
./download.sh "${VERSION}" \
&& unzip -d aquestalk-proxy aquestalk-proxy.zip

FROM wine
COPY --from=downloader --chown=root:root /aquestalk-proxy /app

USER user
EXPOSE 21569
ENTRYPOINT ["/usr/bin/tini", "--", "/usr/bin/wine", "/app/aquestalk-proxy.exe"]
CMD ["--path=/app/aquestalk", "--listen=0.0.0.0:21569"]
44 changes: 44 additions & 0 deletions scripts/download.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash
set -eu

REPOSITORY=Na-x4/aquestalk-proxy
FILENAME=${2-aquestalk-proxy.zip}

if [ -n "${GITHUB_API_TOKEN-}" ]; then
GITHUB_API_HEADERS=(
-H "Authorization: token ${GITHUB_API_TOKEN-}"
)
else
GITHUB_API_HEADERS=()
fi

if [ -n "${1-}" ]; then
version=tags/v${1-}
else
version=latest
fi

release_url="https://api.github.com/repos/$REPOSITORY/releases/$version"
release=$(mktemp)

status_code=$(
curl \
"${GITHUB_API_HEADERS[@]}" \
-H "Accept: application/vnd.github.v3.raw" \
-o "${release}" \
-w '%{http_code}\n' \
"$release_url"
)
if [ "$status_code" != "200" ]; then
jq '.message // .' <"${release}" >&2
exit 1
fi
asset_url=$(jq -re .assets[0].url <"${release}")
rm "${release}"

curl \
"${GITHUB_API_HEADERS[@]}" \
-H "Accept: application/octet-stream" \
-o "$FILENAME" \
-L \
"$asset_url"

0 comments on commit a030962

Please sign in to comment.