Skip to content
This repository has been archived by the owner on Oct 6, 2024. It is now read-only.

chore: update actions workflows #11

chore: update actions workflows

chore: update actions workflows #11

Workflow file for this run

# Actions workflow to release new crates, binaries and terraform
# Author: Nyah Check
name: Release new binaries
on:
workflow_dispatch:
inputs:
reason:
description: Reason for deployment
required: true
push:
tags:
- "*"
env:
CARGO_TERM_COLOR: always
RUST_VERSION: stable
permissions:
contents: write
jobs:
publish-crate-on-new-release:
name: "Publish crate on Release"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ env.RUST_VERSION }}
override: true
components: rustfmt, clippy
- uses: katyo/publish-crates@v2
with:
registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}
- name: create-new-release
uses: softprops/action-gh-release@v1
with:
generate_release_notes: true
files: |
CHANGELOG.md
README.md
SECURITY.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
deploy-new-package:
name: release new musl binary and deploy
runs-on: ubuntu-latest
environment: production
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Fetch musl-rust image
run: |
docker pull clux/muslrust
- name: Build rust release binary
run: |
rustup target add x86_64-unknown-linux-musl
docker run -v $PWD:/volume --rm -t clux/muslrust cargo build --release --target x86_64-unknown-linux-musl
- name: package lambda zip for release
run: |
zip -j lambda.zip ./target/x86_64-unknown-linux-musl/release/bootstrap
cp lambda.zip terraform/lambda.zip
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
with:
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}
env:
TF_VAR_from_email: ${{ secrets.TO_EMAIL }}
TF_VAR_to_email: ${{ secrets.FROM_EMAIL }}
- name: Terraform Format
id: fmt
run: terraform -chdir=terraform fmt -check
- name: Terraform init
id: init
run: terraform -chdir=terraform init
- name: Terraform Validate
id: validate
run: terraform validate -json
- name: Terraform Plan
run: terraform -chdir=terraform plan
- name: Terraform Apply
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
run: terraform -chdir=terraform apply -auto-approve