fix: /invites not .ephemeral #112
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
name: CI | |
on: | |
push: | |
branches: [ master ] | |
tags: [ 'v*' ] | |
pull_request: | |
branches: [ master ] | |
env: | |
CARGO_TERM_COLOR: always | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }} | |
CRATE_NAME: InvitationBot | |
jobs: | |
check: | |
name: Check | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Rust | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
components: rustfmt, clippy | |
- name: Setup sqlx | |
shell: bash | |
env: | |
DATABASE_URL: 'sqlite:.tmp.db' | |
run: | | |
cargo install sqlx-cli | |
cargo sqlx database create | |
cargo sqlx migrate run --source src/migrations | |
cargo sqlx prepare | |
- name: Cache dependencies | |
uses: Swatinem/rust-cache@v2 | |
- name: Copy config | |
run: cp config.example.yaml config.yaml | |
- name: Check formatting | |
run: cargo fmt --all -- --check | |
- name: Clippy | |
run: cargo clippy -- -D warnings | |
- name: Run tests | |
run: cargo test | |
build: | |
name: Build on ${{ matrix.platform.os-name }} with rust ${{ matrix.platform.toolchain || 'stable' }} | |
runs-on: ${{ matrix.platform.runs-on }} | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
RUST_BACKTRACE: 1 | |
strategy: | |
fail-fast: false | |
matrix: | |
platform: | |
- os-name: FreeBSD-x86_64 | |
runs-on: ubuntu-22.04 | |
target: x86_64-unknown-freebsd | |
skip-tests: true | |
cross: true | |
- os-name: Linux-x86_64 | |
runs-on: ubuntu-22.04 | |
target: x86_64-unknown-linux-musl | |
skip-tests: true | |
cross: false | |
- os-name: Linux-x86_64 (native-tls) | |
runs-on: ubuntu-22.04 | |
target: x86_64-unknown-linux-musl | |
features: native-tls | |
skip-tests: true | |
cross: false | |
- os-name: Linux-x86_64 | |
runs-on: ubuntu-22.04 | |
target: x86_64-unknown-linux-gnu | |
skip-tests: true | |
cross: false | |
- os-name: Linux-x86_64 (native-tls) | |
runs-on: ubuntu-22.04 | |
target: x86_64-unknown-linux-gnu | |
features: native-tls | |
skip-tests: true | |
cross: false | |
- os-name: Linux-aarch64 | |
runs-on: ubuntu-22.04 | |
target: aarch64-unknown-linux-musl | |
skip-tests: true | |
cross: true | |
- os-name: Linux-arm | |
runs-on: ubuntu-22.04 | |
target: arm-unknown-linux-musleabi | |
skip-tests: true | |
cross: true | |
- os-name: Linux-i686 | |
runs-on: ubuntu-22.04 | |
target: i686-unknown-linux-musl | |
skip-tests: true | |
cross: true | |
- os-name: Linux-powerpc64 | |
runs-on: ubuntu-22.04 | |
target: powerpc64-unknown-linux-gnu | |
skip-tests: true | |
cross: true | |
- os-name: Linux-powerpc64le | |
runs-on: ubuntu-22.04 | |
target: powerpc64le-unknown-linux-gnu | |
skip-tests: true | |
cross: true | |
- os-name: Linux-riscv64 | |
runs-on: ubuntu-22.04 | |
target: riscv64gc-unknown-linux-gnu | |
skip-tests: true | |
cross: true | |
- os-name: Linux-s390x | |
runs-on: ubuntu-22.04 | |
target: s390x-unknown-linux-gnu | |
skip-tests: true | |
cross: true | |
- os-name: NetBSD-x86_64 | |
runs-on: ubuntu-22.04 | |
target: x86_64-unknown-netbsd | |
skip-tests: true | |
cross: true | |
- os-name: Windows-aarch64 | |
runs-on: windows-latest | |
target: aarch64-pc-windows-msvc | |
skip-tests: true | |
cross: false | |
- os-name: Windows-i686 | |
runs-on: windows-latest | |
target: i686-pc-windows-msvc | |
skip-tests: true | |
cross: false | |
- os-name: Windows-x86_64 | |
runs-on: windows-latest | |
target: x86_64-pc-windows-msvc | |
skip-tests: true | |
cross: false | |
- os-name: macOS-x86_64 | |
runs-on: macOS-latest | |
target: x86_64-apple-darwin | |
skip-tests: true | |
cross: false | |
- os-name: macOS-aarch64 | |
runs-on: macOS-latest | |
target: aarch64-apple-darwin | |
skip-tests: true | |
cross: false | |
- os-name: Linux-x86_64 | |
runs-on: ubuntu-22.04 | |
target: x86_64-unknown-linux-musl | |
bin: InvitationBot | |
toolchain: beta | |
cross: false | |
skip-tests: true | |
- os-name: Linux-x86_64 | |
runs-on: ubuntu-22.04 | |
target: x86_64-unknown-linux-musl | |
bin: InvitationBot | |
toolchain: nightly | |
cross: false | |
skip-tests: true | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set "--features" flag value | |
id: pre | |
shell: bash | |
run: | | |
if [ -n "${{ matrix.platform.features }}" ]; then | |
echo "features=${{ matrix.platform.features }}" >> "$GITHUB_OUTPUT" | |
echo "binary-postfix=-${{ matrix.platform.features }}" >> "$GITHUB_OUTPUT" | |
else | |
echo "features=default" >> "$GITHUB_OUTPUT" | |
echo "binary-postfix=" >> "$GITHUB_OUTPUT" | |
fi | |
if [ -n "${{ matrix.platform.toolchain }}" ]; then | |
echo "toolchain=${{ matrix.platform.toolchain }}" >> "$GITHUB_OUTPUT" | |
else | |
echo "toolchain=stable" >> "$GITHUB_OUTPUT" | |
fi | |
cat "$GITHUB_OUTPUT" | |
- name: Install SSL packages (if required) | |
run: sudo apt-get update --yes && sudo apt-get install --yes pkg-config openssl libssl-dev | |
if: ${{ steps.pre.outputs.features == 'native-tls' }} | |
- name: Install musl (if required) | |
run: sudo apt-get update --yes && sudo apt-get install --yes musl musl-dev musl-tools | |
if: ${{ contains(matrix.platform.target, 'musl') }} | |
- name: Install Rust | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
toolchain: ${{ steps.pre.outputs.toolchain }} | |
target: ${{ matrix.platform.target }} | |
- name: Setup sqlx | |
shell: bash | |
env: | |
DATABASE_URL: 'sqlite:.tmp.db' | |
run: | | |
cargo install sqlx-cli | |
cargo sqlx database create | |
cargo sqlx migrate run --source src/migrations | |
cargo sqlx prepare | |
- name: Cache dependencies | |
uses: Swatinem/rust-cache@v2 | |
with: | |
key: ${{ matrix.platform.target }}-${{ steps.pre.outputs.toolchain }}-${{ steps.pre.outputs.features }} | |
cache-all-crates: true | |
- name: Copy config | |
run: cp config.example.yaml config.yaml | |
- name: Build binary | |
uses: ClementTsang/[email protected] | |
with: | |
command: build | |
args: --locked --release --features ${{ steps.pre.outputs.features }} --target=${{ matrix.platform.target }} | |
use-cross: ${{ matrix.platform.cross }} | |
cross-version: main | |
toolchain: ${{ steps.pre.outputs.toolchain }} | |
env: | |
RUST_BACKTRACE: full | |
- name: Run tests | |
uses: ClementTsang/[email protected] | |
with: | |
command: test | |
args: --locked --release --features ${{ steps.pre.outputs.features }} --target=${{ matrix.platform.target }} | |
use-cross: ${{ matrix.platform.cross }} | |
toolchain: ${{ steps.pre.outputs.toolchain }} | |
if: ${{ !matrix.platform.skip-tests }} | |
env: | |
RUST_BACKTRACE: full | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.CRATE_NAME }}-${{ matrix.platform.target }}${{steps.pre.outputs.binary-postfix }}-${{ steps.pre.outputs.toolchain }} | |
path: target/${{ matrix.platform.target }}/release/${{ env.CRATE_NAME }}* | |
release: | |
name: Release | |
needs: [build] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Tag the repository (pre-release) | |
if: ${{ !startsWith(github.ref, 'refs/tags/v') }} | |
id: tag | |
run: | | |
TAG=v$(date -Iseconds | sed 's/[T:\+]/-/g') | |
TIME=$(date '+%Y/%m/%d %H:%M') | |
echo "$TAG" | |
echo "tag=$TAG" >> $GITHUB_OUTPUT | |
echo "time=$TIME" >> $GITHUB_OUTPUT | |
git config --global user.name "${GITHUB_ACTOR}" | |
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com" | |
git tag -a $TAG -m "Published version $TAG" ${GITHUB_SHA} | |
git push origin $TAG | |
- name: Download artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: artifacts | |
pattern: ${{ env.CRATE_NAME }}-* | |
- name: Rename artifacts | |
shell: bash | |
run: | | |
mkdir -p release | |
ls -la artifacts | |
for dir in artifacts/*; do | |
echo "Processing directory: $dir" | |
ls -la "${dir}" | |
dir_name=$(basename "${dir}") | |
[ -f "${dir}/${CRATE_NAME}" ] && mv "${dir}/${CRATE_NAME}" "release/${dir_name}" | |
[ -f "${dir}/${CRATE_NAME}.exe" ] && mv "${dir}/${CRATE_NAME}.exe" "release/${dir_name}.exe" | |
done | |
ls -la release | |
- name: Create release (pre-release) | |
uses: softprops/action-gh-release@v2 | |
if: ${{ !startsWith(github.ref, 'refs/tags/v') }} | |
with: | |
files: release/* | |
prerelease: true | |
make_latest: false | |
tag_name: ${{ steps.tag.outputs.tag }} | |
name: ${{ steps.tag.outputs.time }} | |
- name: Create release (release) | |
uses: softprops/action-gh-release@v2 | |
if: ${{ startsWith(github.ref, 'refs/tags/v') }} | |
with: | |
files: release/* | |
prerelease: false | |
make_latest: true | |
docker: | |
name: Build and push Docker image | |
needs: [check] | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Log in to the Container registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
tags: | | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
type=sha,format=long | |
type=ref,event=branch | |
type=ref,event=pr | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max |