Skip to content

Release Nightly

Release Nightly #9

name: Release Nightly
on:
workflow_dispatch:
schedule:
# 08:00 AM Beijing Time. Except Tuesday, which is for full release
- cron: "0 0 * * 0,1,3,4,5,6"
jobs:
get-runner-labels:
name: Get Runner Labels
if: github.repository_owner == 'web-infra-dev'
uses: ./.github/workflows/get-runner-labels.yml
build:
name: Build Nightly
if: github.repository_owner == 'web-infra-dev'
needs: [get-runner-labels]
strategy:
fail-fast: false # Build and test everything so we can look at all the errors
matrix:
array:
- target: x86_64-unknown-linux-gnu
runner: ${{ needs.get-runner-labels.outputs.LINUX_RUNNER_LABELS }}
- target: aarch64-unknown-linux-gnu
runner: ${{ needs.get-runner-labels.outputs.LINUX_RUNNER_LABELS }}
- target: x86_64-unknown-linux-musl
runner: ${{ needs.get-runner-labels.outputs.LINUX_RUNNER_LABELS }}
- target: aarch64-unknown-linux-musl
runner: ${{ needs.get-runner-labels.outputs.LINUX_RUNNER_LABELS }}
- target: i686-pc-windows-msvc
runner: ${{ needs.get-runner-labels.outputs.WINDOWS_RUNNER_LABELS }}
- target: x86_64-pc-windows-msvc
runner: ${{ needs.get-runner-labels.outputs.WINDOWS_RUNNER_LABELS }}
- target: aarch64-pc-windows-msvc
runner: ${{ needs.get-runner-labels.outputs.WINDOWS_RUNNER_LABELS }}
- target: x86_64-apple-darwin
runner: ${{ needs.get-runner-labels.outputs.MACOS_RUNNER_LABELS }}
- target: aarch64-apple-darwin
runner: ${{ needs.get-runner-labels.outputs.MACOS_RUNNER_LABELS }}
uses: ./.github/workflows/reusable-build.yml
with:
target: ${{ matrix.array.target }}
runner: ${{ matrix.array.runner }}
release:
name: Release Nightly
if: github.repository_owner == 'web-infra-dev'
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout Main Branch
uses: actions/checkout@v3
- name: Pnpm Cache
uses: ./.github/actions/pnpm-cache
- name: Download artifacts
uses: actions/download-artifact@v3
with:
path: artifacts
- name: Build node packages
run: pnpm run build:js
- name: Move artifacts
run: node scripts/build-npm.cjs
- name: Show binding packages
run: ls -R npm
- name: Resolve dependencies for bindings
run: pnpm install --no-frozen-lockfile
- name: Publish
id: publish
run: |
./x version snapshot
./x publish snapshot --tag nightly
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
REPOSITORY: ${{ github.repository }}
REF: ${{ github.ref }}
ONLY_RELEASE_TAG: true
outputs:
version: ${{ steps.publish.outputs.version }}
trigger-ecosystem-ci:
name: Trigger Ecosystem CI if successed
needs: [release]
runs-on: ubuntu-latest
if: ${{ github.repository_owner == 'web-infra-dev' && !contains(needs.*.result, 'failure') }}
steps:
- uses: actions/github-script@v6
with:
github-token: ${{ secrets.ECOSYSTEM_CI_ACCESS_TOKEN }}
script: |
const result = await github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: 'rspack-ecosystem-ci',
workflow_id: 'ecosystem-ci-selected.yml',
ref: 'main',
inputs: {
refType: 'release',
ref: '${{ needs.release.outputs.version }}',
repo: 'web-infra-dev/rspack',
suite: '-',
suiteRefType: 'precoded',
suiteRef: 'precoded',
}
});
console.log(result);
notify:
name: Notify if failed
needs: [release]
runs-on: ubuntu-latest
if: ${{ github.repository_owner == 'web-infra-dev' && contains(needs.*.result, 'failure') }}
steps:
- uses: actions/github-script@v6
with:
github-token: ${{ secrets.RSPACK_BOT_ACCESS_TOKEN }}
script: |
const res = await fetch(
'${{secrets.DISCORD_WEBHOOK_URL}}',
{
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
username: "nightly release",
avatar_url:
"https://raw.githubusercontent.com/web-infra-dev/rspack-website/main/docs/public/logo.png",
embeds: [
{
title: "nightly release failed",
description: "See job:\n* ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
}
]
})
}
);
console.log("res:", await res.text());