Skip to content

Commit

Permalink
Workflow for automated releases (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
brunojppb authored Feb 11, 2024
1 parent a5ebdd2 commit 899dc58
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
Expand All @@ -27,7 +27,7 @@ jobs:
- name: copy binary
run: |
mkdir out && \
docker cp dist:app/target/release/decay out/decay
docker cp dist:app/target/x86_64-unknown-linux-musl/release/decay out/decay
- uses: actions/upload-artifact@v4
with:
Expand Down
55 changes: 55 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Release new tag
on:
workflow_dispatch:
inputs:
semver:
description: "The SemVer value used by this release"
type: string
required: true

concurrency:
group: ${{ github.ref }}
cancel-in-progress: false

permissions: "write-all"

jobs:
release:
name: Release Turbo Cache Server
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Branch sanity check
if: github.ref != 'refs/heads/main'
run: |
echo "Releases should only run from the main branch"
exit 1
- name: build binary
run: docker build -t rust_build .

- name: create temp container to copy binary from
run: docker create --name dist rust_build

# Copy binary from the Docker container and put
# it within the `action` directory before commiting the new tag.
# This makes the binary available directly from the tag
# when using this repo as a Github Action, without requiring
# an extra binary download from somewhere else (Github Releases?)
# leading to a faster pipeline.
- name: copy binary
run: |
docker cp dist:app/target/x86_64-unknown-linux-musl/release/decay action/decay
chmod +x action/decay
- name: Commit new binary
run: |
git config --global user.name "${GITHUB_ACTOR}"
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git add action/decay
git commit -am "Release ${{ github.event.inputs.semver }}"
git tag -a ${{ github.event.inputs.semver }} -m "Release ${{ github.event.inputs.semver }}"
- name: Push new tag
run: git push origin ${{ github.event.inputs.semver }}
11 changes: 11 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ rust-s3 = "0.33.0"
serde = { version = "1.0", features = ["derive"] }
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
futures = "0.3"
openssl = { version = "0.10", features = ["vendored"] }

[dev-dependencies]
reqwest = "0.11.23"
Expand Down
8 changes: 6 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
FROM rust as builder
# To make Decay compatible with differnt linux distributions,
# let's cross-compile using musl so the binary is statically linked with the right dependencies
# See: https://users.rust-lang.org/t/unable-to-run-compiled-program/88441/5
# See: https://github.com/rust-cross/rust-musl-cross
FROM messense/rust-musl-cross:x86_64-musl as builder
WORKDIR /app
COPY . /app
RUN cargo check && cargo build --verbose --release
RUN cargo build --verbose --release

0 comments on commit 899dc58

Please sign in to comment.