Skip to content

build

build #1393

Workflow file for this run

name: build
on:
push:
branches:
- main
schedule:
- cron: '0 4 * * MON-FRI' # run every weekday at 4AM (https://docs.github.com/en/actions/reference/events-that-trigger-workflows#scheduled-events-schedule)
workflow_dispatch:
pull_request:
branches:
- main
jobs:
build:
env:
BUILD_OUTPUT_DIRECTORY: dist
EXECUTABLE_NAME: arduino-language-server
strategy:
matrix:
config:
- os: ubuntu-latest
ExecutableSuffix: ''
Exports: ''
- os: macos-latest
ExecutableSuffix: ''
Exports: 'CGO_ENABLED=1 MACOSX_DEPLOYMENT_TARGET=10.14 '
- os: windows-2019
ExecutableSuffix: '.exe'
Exports: ''
runs-on: ${{ matrix.config.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: '1.21.5'
- name: Build and Test
run: |
${{ matrix.config.Exports }}go build -o "${{ github.workspace }}/${{ env.BUILD_OUTPUT_DIRECTORY }}/${{ runner.OS }}_amd64/${{ env.EXECUTABLE_NAME }}${{ matrix.config.ExecutableSuffix }}"
go test ./...
- name: Create archive
run: 7z a "${{ github.workspace }}/${{ env.BUILD_OUTPUT_DIRECTORY }}/archive/${{ env.EXECUTABLE_NAME }}_${{ runner.OS }}_amd64.zip" "${{ github.workspace }}/${{ env.BUILD_OUTPUT_DIRECTORY }}/${{ runner.OS }}_amd64/*"
- name: Upload Workflow Artifact [GitHub Actions]
uses: actions/upload-artifact@v3
with:
name: build-artifacts
# this makes the artifact a .zip of the .zip archive, which is currently necessary to preserve the executable file permissions
# see: https://github.com/actions/upload-artifact/issues/38
path: ${{ env.BUILD_OUTPUT_DIRECTORY }}/archive/${{ env.EXECUTABLE_NAME }}_${{ runner.OS }}_amd64.zip
publish:
needs: build
if: github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main')
runs-on: ubuntu-latest
steps:
- name: Download Workflow Artifact [GitHub Actions]
uses: actions/download-artifact@v3
with:
name: build-artifacts
path: build-artifacts
- name: Publish Nightly [S3]
uses: docker://plugins/s3
env:
PLUGIN_SOURCE: "build-artifacts/*"
PLUGIN_TARGET: "/arduino-language-server/nightly"
PLUGIN_STRIP_PREFIX: "build-artifacts/"
PLUGIN_BUCKET: ${{ secrets.DOWNLOADS_BUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}