Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update crates and add some sub command/options #13

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: CI
on:
pull_request:
types:
- opened
- edited
- reopened
- synchronize

env:
CARGO_TERM_COLOR: always
RUST_TARGET: x86_64-unknown-linux-musl

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build and test
uses: gmiam/rust-musl-action@master
with:
args: make build && make ut
118 changes: 118 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
name: release

on:
push:
tags:
- v[0-9]+.[0-9]+.[0-9]+*
workflow_dispatch:

env:
CARGO_TERM_COLOR: always
RUST_TARGET: x86_64-unknown-linux-musl
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build toml cli
# uses: juankaram/rust-musl-action@master
uses: gmiam/rust-musl-action@master
with:
args: cargo build --target $RUST_TARGET --release
- name: store-artifacts
uses: actions/upload-artifact@v2
with:
if-no-files-found: error
name: toml-artifacts-linux
path: |
target/${{ env.RUST_TARGET }}/release/toml

prepare-tarball-linux:
runs-on: ubuntu-latest
needs: [build-linux]
steps:
- name: download artifacts
uses: actions/download-artifact@v2
with:
name: toml-artifacts-linux
path: toml-cli
- name: prepare release tarball
run: |
tag=$(echo $GITHUB_REF | cut -d/ -f3-)
tarball="toml-cli-$tag-linux-amd64.tgz"
chmod +x toml-cli/*
tar cf - toml-cli | gzip > ${tarball}
echo "tarball=${tarball}" >> $GITHUB_ENV

shasum="$tarball.sha256sum"
sha256sum $tarball > $shasum
echo "tarball_shasum=${shasum}" >> $GITHUB_ENV
- name: store-artifacts
uses: actions/upload-artifact@v2
with:
name: release-tarball
path: |
${{ env.tarball }}
${{ env.tarball_shasum }}

create-release:
runs-on: ubuntu-latest
needs: [prepare-tarball-linux]
steps:
- name: download artifacts
uses: actions/download-artifact@v2
with:
name: release-tarball
path: tarballs
- name: prepare release env
run: |
echo "tarballs<<EOF" >> $GITHUB_ENV
for I in $(ls tarballs);do echo "tarballs/${I}" >> $GITHUB_ENV; done
echo "EOF" >> $GITHUB_ENV
tag=$(echo $GITHUB_REF | cut -d/ -f3-)
echo "tag=${tag}" >> $GITHUB_ENV
cat $GITHUB_ENV
- name: push release
if: github.event_name == 'push'
uses: softprops/action-gh-release@v1
with:
name: "Toml cli ${{ env.tag }}"
body: |
"Toml cli release ${{ env.tag }}"
generate_release_notes: true
files: |
${{ env.tarballs }}

publish-image:
runs-on: ubuntu-latest
needs: [build-linux]
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Log in to the container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: download artifacts
uses: actions/download-artifact@v2
with:
name: toml-artifacts-linux
path: misc
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: build and push toml cli image
uses: docker/build-push-action@v3
with:
context: misc
file: misc/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/target
**/*.rs.bk
toml
Loading