Skip to content

Commit

Permalink
Add release GitHub action
Browse files Browse the repository at this point in the history
  • Loading branch information
franciscoadasme committed Dec 17, 2024
1 parent 2964b3c commit 3748731
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Build a release

on:
push:
tags:
- "v*"

jobs:
build:
name: Build
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-13, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Crystal
uses: crystal-lang/install-crystal@v1
- name: Install dependencies
run: shards install --production
- name: Inject slug/short variables
uses: rlespinasse/github-slug-action@v5
- name: Set architecture environment variable
run: |
if [ "$RUNNER_ARCH" == "X64" ]; then
echo "ARCH=x86_64" >> $GITHUB_ENV
elif [ "$RUNNER_ARCH" == "ARM64" ]; then
echo "ARCH=arm64" >> $GITHUB_ENV
else
echo "ARCH=unknown" >> $GITHUB_ENV
fi
- if: matrix.os == 'ubuntu-latest'
name: Build binary (Linux)
run: |
mkdir bin
docker run --rm -it -v $(pwd):/workspace -w /workspace \
crystallang/crystal:latest-alpine \
crystal build --static --release --debug \
-o bin/moltiverse-${GITHUB_REF_SLUG}-linux-${ARCH} \
src/moltiverse.cr
- if: startsWith(matrix.os, 'macos')
name: Build binary (macOS)
run: |
mkdir bin
crystal build --release --debug \
-o bin/moltiverse-${GITHUB_REF_SLUG}-osx-${ARCH} \
src/moltiverse.cr
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: bin-${{ matrix.os }}
path: bin
- name: Upload to GitHub Releases
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref }}
overwrite: true
file_glob: true
file: bin/*

0 comments on commit 3748731

Please sign in to comment.