-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -116,3 +116,48 @@ jobs: | |
files: | | ||
nichijid-rs-windows.zip | ||
nichijid-rs-linux.zip | ||
- uses: docker/[email protected] | ||
|
||
- uses: docker/[email protected] | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Create tagname | ||
id: tagname | ||
run: | | ||
VERSION="$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')" | ||
# 2193: ${{ github.ref }} will replaced by GitHub Actions | ||
# shellcheck disable=SC2193 | ||
[[ "${{ github.ref }}" == refs/tags/* ]] && VERSION="${VERSION/v/}" | ||
[[ "$VERSION" == "master" ]] && VERSION=latest | ||
# shellcheck disable=SC2193 | ||
[[ "${{ github.ref }}" == refs/pull/* ]] && VERSION=dontpush | ||
echo "$VERSION" | ||
echo "version=$VERSION" >> "$GITHUB_OUTPUT" | ||
- name: Build and Push | ||
uses: docker/[email protected] | ||
if: "! startsWith(github.ref, 'refs/pull/')" | ||
with: | ||
context: . | ||
platforms: linux/amd64 | ||
push: true | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
tags: | | ||
ghcr.io/yanorei32/nichijid-rs:${{ steps.tagname.outputs.version }} | ||
- name: Build and Push | ||
uses: docker/[email protected] | ||
if: "startsWith(github.ref, 'refs/pull/')" | ||
with: | ||
context: . | ||
platforms: linux/amd64 | ||
push: false | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
tags: | | ||
ghcr.io/yanorei32/nichijid-rs:${{ steps.tagname.outputs.version }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
FROM rust:1.71.1 as build-env | ||
LABEL maintainer="yanorei32" | ||
|
||
SHELL ["/bin/bash", "-o", "pipefail", "-c"] | ||
|
||
WORKDIR /usr/src | ||
RUN cargo new nichijid-rs | ||
COPY LICENSE Cargo.toml Cargo.lock /usr/src/nichijid-rs/ | ||
WORKDIR /usr/src/nichijid-rs | ||
ENV CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse | ||
RUN cargo install cargo-license && cargo license \ | ||
--authors \ | ||
--do-not-bundle \ | ||
--avoid-dev-deps \ | ||
--avoid-build-deps \ | ||
--filter-platform "$(rustc -vV | sed -n 's|host: ||p')" \ | ||
> CREDITS | ||
|
||
RUN cargo build --release | ||
COPY src/ /usr/src/nichijid-rs/src/ | ||
|
||
RUN touch src/* && cargo build --release | ||
|
||
FROM debian:bullseye-slim@sha256:5e8651093bdb71901c1c60bb95c1d35e0975e0a1a0c6207ca2662b675e2ec323 | ||
|
||
WORKDIR / | ||
|
||
COPY --chown=root:root --from=build-env \ | ||
/usr/src/nichijid-rs/CREDITS \ | ||
/usr/src/nichijid-rs/LICENSE \ | ||
/usr/share/licenses/nichijid-rs/ | ||
|
||
COPY --chown=root:root --from=build-env \ | ||
/usr/src/nichijid-rs/target/release/nichijid-rs \ | ||
/usr/bin/nichijid-rs | ||
|
||
CMD ["/usr/bin/nichijid-rs"] |