Build: Automatic #938
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: Build | |
| run-name: "Build: ${{ github.event_name != 'workflow_dispatch' && 'Automatic' || 'Release' }}" | |
| on: | |
| push: | |
| branches: | |
| - "**" | |
| paths-ignore: | |
| - '**/*.md' | |
| pull_request: | |
| branches: | |
| - '**' | |
| paths-ignore: | |
| - '**/*.md' | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| jobs: | |
| lint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-go@v5 | |
| with: | |
| go-version: "1.25" | |
| - uses: golangci/golangci-lint-action@v8 | |
| with: | |
| version: v2.4 | |
| prepare-validate: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| targets: ${{ steps.generate.outputs.targets }} | |
| steps: | |
| - | |
| name: Checkout | |
| uses: actions/checkout@v4 | |
| - | |
| name: List targets | |
| id: generate | |
| uses: docker/bake-action/subaction/list-targets@v6 | |
| with: | |
| target: validate | |
| validate: | |
| runs-on: ubuntu-latest | |
| needs: | |
| - prepare-validate | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| target: ${{ fromJson(needs.prepare-validate.outputs.targets) }} | |
| steps: | |
| - | |
| name: Checkout | |
| uses: actions/checkout@v4 | |
| - | |
| name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - | |
| name: Validate | |
| uses: docker/bake-action@v6 | |
| with: | |
| source: . | |
| targets: ${{ matrix.target }} | |
| build: | |
| runs-on: ubuntu-latest | |
| needs: | |
| - lint | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Update Docker to 28.0.1 | |
| run: | | |
| sudo systemctl stop docker.service | |
| sudo apt-get purge docker-ce docker-ce-cli containerd.io docker-compose-plugin docker-ce-rootless-extras docker-buildx-plugin | |
| sudo apt-get install curl | |
| curl -fsSL https://test.docker.com -o get-docker.sh | |
| sudo sh ./get-docker.sh --version 28.0.1 | |
| - uses: docker/setup-buildx-action@v3 | |
| with: | |
| use: true | |
| - run: docker build -t docker/lsp:test --target test . | |
| - run: docker run --rm -v /var/run/docker.sock:/var/run/docker.sock docker/lsp:test make test | |
| windows-test: | |
| runs-on: windows-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-go@v5 | |
| with: | |
| go-version: "1.25" | |
| - name: Run unit tests | |
| env: | |
| DOCKER_LANGUAGE_SERVER_WINDOWS_CI: true | |
| run: go test -timeout 30s github.com/docker/docker-language-server/internal/bake/hcl github.com/docker/docker-language-server/internal/bake/hcl/parser github.com/docker/docker-language-server/internal/compose github.com/docker/docker-language-server/internal/dockerfile github.com/docker/docker-language-server/internal/pkg/buildkit github.com/docker/docker-language-server/internal/pkg/document github.com/docker/docker-language-server/internal/scout github.com/docker/docker-language-server/internal/telemetry github.com/docker/docker-language-server/internal/types github.com/docker/docker-language-server/releaser | |
| - name: Run e2e tests | |
| env: | |
| DOCKER_LANGUAGE_SERVER_WINDOWS_CI: true | |
| run: go test -timeout 240s github.com/docker/docker-language-server/e2e-tests | |
| integration-test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: actions/checkout@v4 (docker/docker-language-server) | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: docker/docker-language-server | |
| path: docker-language-server | |
| - name: actions/checkout@v4 (docker/vscode-extension) | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: docker/vscode-extension | |
| path: vscode-extension | |
| - uses: actions/setup-go@v5 | |
| with: | |
| go-version: "1.25" | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: "22.x" | |
| - run: make build | |
| working-directory: docker-language-server | |
| - run: npm install | |
| working-directory: vscode-extension | |
| - name: Replace the downloaded binary with the one from the build | |
| working-directory: vscode-extension | |
| run: | | |
| rm bin/* | |
| mv ../docker-language-server/docker-language-server-linux-amd64 bin | |
| - run: sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0 | |
| working-directory: vscode-extension | |
| - run: xvfb-run --auto-servernum --server-args='-screen 0 1920x1080x24' npm test | |
| working-directory: vscode-extension | |
| upload: | |
| if: github.event_name != 'workflow_dispatch' | |
| needs: | |
| - build | |
| - integration-test | |
| - windows-test | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| os: [linux, windows, darwin] | |
| arch: [amd64, arm64] | |
| include: | |
| - os: windows | |
| ext: .exe | |
| - os: linux | |
| ext: "" | |
| - os: darwin | |
| ext: "" | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-go@v5 | |
| with: | |
| go-version: "1.25" | |
| - name: Build for ${{ matrix.os }}-${{ matrix.arch }} | |
| run: | | |
| GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} BUGSNAG_API_KEY=${{ secrets.BUGSNAG_API_KEY }} TELEMETRY_ENDPOINT=${{ vars.TELEMETRY_ENDPOINT }} TELEMETRY_KEY=${{ secrets.TELEMETRY_KEY }} make build | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: docker-language-server-${{ matrix.os }}-${{ matrix.arch }}${{ matrix.ext }} | |
| path: docker-language-server-${{ matrix.os }}-${{ matrix.arch }}${{ matrix.ext }} | |
| if-no-files-found: error | |
| create-release: | |
| if: github.event_name == 'workflow_dispatch' | |
| runs-on: ubuntu-latest | |
| needs: | |
| - build | |
| - integration-test | |
| - windows-test | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-go@v5 | |
| with: | |
| go-version: "1.25" | |
| - name: Extract new version from changelog | |
| id: version | |
| # Extract the version from the first ## header in CHANGELOG.md | |
| run: | | |
| NEW_VERSION=$(grep -m 1 "^## \[" CHANGELOG.md | sed 's/^## \[\([^]]*\)\].*/\1/') | |
| echo "New version: $NEW_VERSION" | |
| echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT | |
| - name: Generate release notes | |
| run: | | |
| go run ./releaser/main.go generate-release-notes > release-notes.tmp | |
| - name: Get current date | |
| if: github.event_name == 'workflow_dispatch' | |
| id: date | |
| run: echo "current_date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT | |
| - uses: softprops/action-gh-release@c062e08bd532815e2082a85e87e3ef29c3e6d191 # v2.0.8 https://github.com/softprops/action-gh-release/commit/c062e08bd532815e2082a85e87e3ef29c3e6d191 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| name: v${{ steps.version.outputs.new_version }} - ${{ steps.date.outputs.current_date }} | |
| tag_name: v${{ steps.version.outputs.new_version }} | |
| body_path: release-notes.tmp | |
| fail_on_unmatched_files: true | |
| upload-release-binaries: | |
| runs-on: ubuntu-latest | |
| needs: | |
| - create-release | |
| strategy: | |
| matrix: | |
| os: [linux, windows, darwin] | |
| arch: [amd64, arm64] | |
| include: | |
| - os: windows | |
| ext: .exe | |
| - os: linux | |
| ext: "" | |
| - os: darwin | |
| ext: "" | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-tags: true | |
| - uses: actions/setup-go@v5 | |
| with: | |
| go-version: "1.25" | |
| - name: Set variables | |
| id: set-variables | |
| # Extract the version from the first ## header in CHANGELOG.md | |
| run: | | |
| VERSION=$(grep -m 1 "^## \[" CHANGELOG.md | sed 's/^## \[\([^]]*\)\].*/\1/') | |
| echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT" | |
| - name: Build for ${{ matrix.os }}-${{ matrix.arch }} | |
| run: | | |
| GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} BUGSNAG_API_KEY=${{ secrets.BUGSNAG_API_KEY }} TELEMETRY_ENDPOINT=${{ vars.TELEMETRY_ENDPOINT }} TELEMETRY_KEY=${{ secrets.TELEMETRY_KEY }} make build | |
| - name: Rename the binary to include the version number | |
| run: | | |
| mv docker-language-server-${{ matrix.os }}-${{ matrix.arch }}${{ matrix.ext }} docker-language-server-${{ matrix.os }}-${{ matrix.arch }}-v${{ steps.set-variables.outputs.VERSION }}${{ matrix.ext }} | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: docker-language-server-${{ matrix.os }}-${{ matrix.arch }}-v${{ steps.set-variables.outputs.VERSION }}${{ matrix.ext }} | |
| path: docker-language-server-${{ matrix.os }}-${{ matrix.arch }}-v${{ steps.set-variables.outputs.VERSION }}${{ matrix.ext }} | |
| if-no-files-found: error | |
| - uses: softprops/action-gh-release@c062e08bd532815e2082a85e87e3ef29c3e6d191 # v2.0.8 https://github.com/softprops/action-gh-release/commit/c062e08bd532815e2082a85e87e3ef29c3e6d191 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| tag_name: v${{ steps.set-variables.outputs.VERSION }} | |
| files: docker-language-server-${{ matrix.os }}-${{ matrix.arch }}-v${{ steps.set-variables.outputs.VERSION }}${{ matrix.ext }} | |
| fail_on_unmatched_files: true |