Skip to content

release-nightly

release-nightly #812

name: release-nightly
on:
workflow_dispatch:
schedule:
- cron: '45 0 * * *'
env:
CARGO_TERM_COLOR: always
RUSTFLAGS: "-D warnings"
jobs:
nightly-last-run:
runs-on: ubuntu-latest
name: Check latest commit
outputs:
should_run: ${{ steps.should_run.outputs.should_run }}
if: ${{ github.repository_owner == 'gleam-lang' }}
steps:
- uses: actions/checkout@v4
- name: print latest_commit
run: echo ${{ github.sha }}
- id: should_run
continue-on-error: true
name: check latest commit is less than a day
if: ${{ github.event_name == 'schedule' }}
run: test -z $(git rev-list --after="24 hours" ${{ github.sha }}) && echo "should_run=false" >> $GITHUB_OUTPUT
build-nightly-clean:
runs-on: ubuntu-latest
needs: [ nightly-last-run ]
if: ${{ github.repository_owner == 'gleam-lang' && needs.nightly-last-run.outputs.should_run != 'false' }}
steps:
- name: Delete old release assets
uses: mknejp/delete-release-assets@v1
with:
token: ${{ github.token }}
tag: nightly
fail-if-no-assets: false
fail-if-no-release: false
assets: |
*.zip
*.tar.gz
*.sha256
*.sha512
build-nightly:
name: build-release
runs-on: ${{ matrix.os }}
needs: [ build-nightly-clean ]
if: ${{ github.repository_owner == 'gleam-lang' }}
strategy:
matrix:
target:
- x86_64-unknown-linux-musl
- aarch64-unknown-linux-musl
- x86_64-apple-darwin
- aarch64-apple-darwin
- x86_64-pc-windows-msvc
toolchain: [stable]
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
use-cross: true
- os: ubuntu-latest
target: aarch64-unknown-linux-musl
use-cross: true
- os: macos-latest
target: x86_64-apple-darwin
use-cross: false
- os: macos-12
target: aarch64-apple-darwin
use-cross: false
- os: windows-latest
target: x86_64-pc-windows-msvc
use-cross: false
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Update versions
shell: bash
run: |
./bin/add-nightly-suffix-to-versions.sh
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ matrix.toolchain }}
target: ${{ matrix.target }}
- name: Handle Rust dependencies caching
uses: Swatinem/rust-cache@v2
with:
key: v1-${{ matrix.target }}
- name: Build release binary
uses: clechasseur/rs-cargo@v2
with:
command: build
args: --release --target ${{ matrix.target }}
use-cross: ${{ matrix.use-cross }}
- name: Build archive
shell: bash
run: |
VERSION=nightly
DAY=$(date +"%y%m%d")
if [ "${{ matrix.os }}" = "windows-latest" ]; then
ARCHIVE="gleam-$VERSION-${{ matrix.target }}.zip"
cp "target/${{ matrix.target }}/release/gleam.exe" "gleam.exe"
7z a "$ARCHIVE" "gleam.exe"
rm gleam.exe
else
ARCHIVE="gleam-$VERSION-${{ matrix.target }}.tar.gz"
cp "target/${{ matrix.target }}/release/gleam" "gleam"
tar -czvf "$ARCHIVE" "gleam"
rm gleam
fi
openssl dgst -r -sha256 -out "$ARCHIVE".sha256 "$ARCHIVE"
openssl dgst -r -sha512 -out "$ARCHIVE".sha512 "$ARCHIVE"
echo "ASSET=$ARCHIVE" >> $GITHUB_ENV
echo "DAY=$DAY" >> $GITHUB_ENV
- name: Ensure binary successfully boots
shell: bash
run: |
case "${{ matrix.target }}" in
x86_64-pc-windows-msvc)
7z x "$ASSET"
./gleam.exe --version ;;
aarch64*)
echo "We cannot test an ARM binary on a AMD64 runner" ;;
*)
tar -xvzf "$ASSET"
./gleam --version ;;
esac
- name: Upload release archive
shell: bash
run: |
for i in $(seq 5); do
gh release upload nightly --clobber \
"${{ env.ASSET }}" \
"${{ env.ASSET }}.sha256" \
"${{ env.ASSET }}.sha512" \
&& break
done
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload x86_64-unknown-linux-musl artifact
uses: actions/upload-artifact@v4
with:
name: gleam-amd64
path: target/${{ matrix.target }}/release/gleam
overwrite: true
if: ${{ matrix.target == 'x86_64-unknown-linux-musl' }}
- name: Upload aarch64-unknown-linux-musl artifact
uses: actions/upload-artifact@v4
with:
name: gleam-arm64
path: target/${{ matrix.target }}/release/gleam
overwrite: true
if: ${{ matrix.target == 'aarch64-unknown-linux-musl' }}
build-nightly-container-images:
runs-on: ubuntu-latest
needs: [ build-nightly ]
if: ${{ github.repository_owner == 'gleam-lang' && needs.nightly-last-run.outputs.should_run != 'false' }}
strategy:
matrix:
base-image:
- erlang
- erlang-slim
- erlang-alpine
- elixir
- elixir-slim
- elixir-alpine
- node
- node-slim
- node-alpine
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download Gleam amd binary from previous job
uses: actions/download-artifact@v4
with:
name: gleam-amd64
path: ./gleam-amd64
- name: Download Gleam arm binary from previous job
uses: actions/download-artifact@v4
with:
name: gleam-arm64
path: ./gleam-arm64
- name: Authenticate with GitHub container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: lpil
password: ${{ secrets.CONTAINER_REGISTRY_PERSONAL_ACCESS_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
file: containers/${{ matrix.base-image }}.dockerfile
push: true
tags: ${{ steps.versions.outputs.container_tag }}
ghcr.io/${{ github.repository }}:nightly-${{ matrix.base-image }}
labels: |
org.opencontainers.image.title=gleam
org.opencontainers.image.url=https://gleam.run
org.opencontainers.image.source=https://github.com/gleam-lang/gleam
org.opencontainers.image.version=nightly-${{ matrix.base-image }}
org.opencontainers.image.licenses=Apache-2.0