Deploy #6
Workflow file for this run
This file contains hidden or 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: Deploy | |
permissions: | |
contents: write | |
on: | |
push: | |
tags: | |
- huly-coder-v* | |
workflow_dispatch: # allows you to run this workflow manually from the Actions tab | |
env: | |
CARGO_INCREMENTAL: 0 | |
CARGO_NET_GIT_FETCH_WITH_CLI: true | |
CARGO_NET_RETRY: 10 | |
CARGO_TERM_COLOR: always | |
RUST_BACKTRACE: 1 | |
RUSTFLAGS: -D warnings | |
RUSTUP_MAX_RETRIES: 10 | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
upload-assets: | |
name: ${{ matrix.target }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
include: | |
- name: darwin-arm64 | |
target: aarch64-apple-darwin | |
os: macos-13 | |
- name: linux-x64-glibc | |
target: x86_64-unknown-linux-gnu | |
os: ubuntu-22.04 | |
- name: darwin-x64 | |
target: x86_64-apple-darwin | |
os: macos-13 | |
- name: win32-x64-msvc | |
target: x86_64-pc-windows-msvc | |
os: windows-2022 | |
timeout-minutes: 60 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set the release version | |
shell: bash | |
# Extract the version number from the "refs/tags/huly-coder-vx.x.x" | |
run: echo "RELEASE_VERSION=${GITHUB_REF:22}" >> $GITHUB_ENV | |
- name: Install Rust toolchain | |
uses: actions-rust-lang/setup-rust-toolchain@v1 | |
- name: Upload binaries to release | |
uses: taiki-e/upload-rust-binary-action@v1 | |
with: | |
bin: huly-coder | |
target: ${{ matrix.target }} | |
include: LICENSE,README.md,huly-coder.yaml | |
tar: all | |
zip: windows | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Install node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
registry-url: "https://registry.npmjs.org" | |
- name: Publish to NPM | |
shell: bash | |
run: | | |
cd npm | |
bin="huly-coder" | |
node_os=$(echo "${{ matrix.name }}" | cut -d '-' -f1) | |
export node_os | |
node_arch=$(echo "${{ matrix.name }}" | cut -d '-' -f2) | |
export node_arch | |
export version="${{ env.RELEASE_VERSION }}" | |
if [ "${{ matrix.os }}" = "windows-2022" ]; then | |
export node_pkg="${bin}-windows-${node_arch}" | |
else | |
export node_pkg="${bin}-${node_os}-${node_arch}" | |
fi | |
mkdir -p "${node_pkg}/bin" | |
envsubst < package.json.tmpl > "${node_pkg}/package.json" | |
if [ "${{ matrix.os }}" = "windows-2022" ]; then | |
bin="${bin}.exe" | |
fi | |
cp "../target/${{ matrix.target }}/release/${bin}" "${node_pkg}/bin" | |
cp ../README.md "${node_pkg}" | |
cp ../huly-coder.yaml "${node_pkg}" | |
cd "${node_pkg}" | |
npm publish | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
upload-docker: | |
name: Build & Push Docker Image | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USER }} | |
password: ${{ secrets.DOCKER_ACCESS_TOKEN }} | |
- run: echo VERSION=$(grep '^version =' Cargo.toml | cut -d '"' -f 2) >> $GITHUB_ENV | |
- name: Build and Push | |
uses: docker/build-push-action@v6 | |
with: | |
file: Dockerfile | |
push: true | |
tags: "${{ secrets.DOCKER_USER }}/huly-coder:${{ env.VERSION }},${{ secrets.DOCKER_USER }}/huly-coder:latest" | |
platforms: linux/amd64,linux/arm64 | |
publish-npm: | |
name: Publish the base package to NPM | |
needs: upload-assets | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set the release version | |
shell: bash | |
# Extract the version number from the "refs/tags/huly-coder-vx.x.x" | |
run: echo "RELEASE_VERSION=${GITHUB_REF:22}" >> $GITHUB_ENV | |
- name: Install node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
registry-url: "https://registry.npmjs.org" | |
- name: Publish the package | |
shell: bash | |
working-directory: npm/huly-coder | |
run: | | |
export version="${{ env.RELEASE_VERSION }}" | |
envsubst < ../main-package.json.tmpl > "package.json" | |
yarn config set npmAuthToken ${NODE_AUTH_TOKEN} | |
yarn config set npmPublishRegistry "https://registry.npmjs.org" | |
yarn install | |
yarn build | |
cp ../../README.md . | |
cp ../../CHANGELOG.md . | |
yarn npm publish | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
YARN_ENABLE_IMMUTABLE_INSTALLS: false |