TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Automatically publishing your build artifacts

23 pointsby agateaualmost 4 years ago

3 comments

dnsmichialmost 4 years ago
Hi, interesting post, thanks. Sharing how you can do it with GitLab :) Start with defining artifacts in the job config, and download them directly in the MR during the review &amp; QA process. <a href="https:&#x2F;&#x2F;docs.gitlab.com&#x2F;ee&#x2F;ci&#x2F;pipelines&#x2F;job_artifacts.html" rel="nofollow">https:&#x2F;&#x2F;docs.gitlab.com&#x2F;ee&#x2F;ci&#x2F;pipelines&#x2F;job_artifacts.html</a><p>build-job:<p><pre><code> script: - .&#x2F;build-dist-artifacts.sh artifacts: paths: - dist&#x2F;* </code></pre> Engineers can use `filter pipelines` to find specific branches, tags, etc. they are looking for.<p>Large binary files may consume lots of storage, and need regular cleanup. `expire_in` allows to control the cleanup in GitLab. For older builds, you can always retry the build job&#x2F;pipeline, and generate artifacts on demand, i.e. when debugging a problem between older release versions.<p>This is helpful for tarballs, also RPM&#x2F;DEB packages, etc - anything which requires time and knowledge to build manually on a local development environment. With GitLab API access, you can integrate the job artifacts into more automated workflows or custom index websites of your choice, leaving the storage as SSoT in GitLab.<p><a href="https:&#x2F;&#x2F;docs.gitlab.com&#x2F;ee&#x2F;api&#x2F;job_artifacts.html#download-a-single-artifact-file-from-specific-tag-or-branch" rel="nofollow">https:&#x2F;&#x2F;docs.gitlab.com&#x2F;ee&#x2F;api&#x2F;job_artifacts.html#download-a...</a><p>The job artifacts can be put into a cloud object storage, like S3, too. <a href="https:&#x2F;&#x2F;docs.gitlab.com&#x2F;ee&#x2F;administration&#x2F;job_artifacts.html#using-object-storage" rel="nofollow">https:&#x2F;&#x2F;docs.gitlab.com&#x2F;ee&#x2F;administration&#x2F;job_artifacts.html...</a><p>Last but but not least: If you prefer building your own file index based on smaller sized artifacts, you could use GitLab Pages and follow this post: <a href="https:&#x2F;&#x2F;forum.gitlab.com&#x2F;t&#x2F;how-to-allow-directory-listing-on-gitlab-com-pages&#x2F;20625&#x2F;7" rel="nofollow">https:&#x2F;&#x2F;forum.gitlab.com&#x2F;t&#x2F;how-to-allow-directory-listing-on...</a> to publish the artifacts and create an html index.<p>I&#x27;ve done a similar approach to publish custom code coverage reports in CI&#x2F;CD in a past workshop: <a href="https:&#x2F;&#x2F;gitlab.com&#x2F;gitlab-de&#x2F;workshops&#x2F;ci-monitoring-webcast-2020&#x2F;-&#x2F;blob&#x2F;main&#x2F;.gitlab-ci.yml#L80" rel="nofollow">https:&#x2F;&#x2F;gitlab.com&#x2F;gitlab-de&#x2F;workshops&#x2F;ci-monitoring-webcast...</a> - can be handy for reviews and QA checks too.
arwineapalmost 4 years ago
If you don&#x27;t publish your build artifacts, what are you deploying?
评论 #27584425 未加载
techplexalmost 4 years ago
I often &quot;publish&quot; artifacts internally in github actions with the actions&#x2F;upload-artifact action. <a href="https:&#x2F;&#x2F;github.com&#x2F;actions&#x2F;upload-artifact" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;actions&#x2F;upload-artifact</a><p>&#x2F;&#x2F;.github&#x2F;workflows&#x2F;main.yml<p><pre><code> name: Main on: push: branches: [ main ] pull_request: branches: [ main ] jobs: build: runs-on: self-hosted steps: - uses: actions&#x2F;checkout@v2 - name: Set up Go uses: actions&#x2F;setup-go@v2 with: go-version: 1.16 - name: Test run: go test -v .&#x2F;... - name: Build Discover Command run: go build -o discover cmd&#x2F;discover&#x2F;main.go - name: Upload Build Artifacts uses: actions&#x2F;upload-artifact@v2 with: name: discover path: discover </code></pre> For internal tooling we often publish tagged artifacts to releases on the repo using a workflow that is triggered when someone creates a release. The creation of the release makes a new tag and triggers the build.<p>&#x2F;&#x2F;.github&#x2F;workflows&#x2F;release.yml<p><pre><code> name: Release on: release: types: - published jobs: build: runs-on: self-hosted env: GOPRIVATE: &quot;github.com&#x2F;OUR-ORG-NAME&#x2F;\*&quot; NAME: deploy-${{ github.event.release.tag_name }}-${{ matrix.GOOS }}-${{ matrix.GOARCH }}${{ matrix.EXTENSION }} strategy: matrix: GOOS: [ windows, linux, darwin ] GOARCH: [ amd64, 386 ] exclude: # excludes 32bit on macOS - GOOS: darwin GOARCH: 386 include: # includes a new variable for windows builds - GOOS: windows EXTENSION: &quot;.exe&quot; steps: # Runs a single command using the runners shell - name: Print Info run: echo &#x27;${{ toJSON(github.event.release) }}&#x27; - uses: actions&#x2F;checkout@v2 - name: Set up Go uses: actions&#x2F;setup-go@v2 with: go-version: 1.16 # From https:&#x2F;&#x2F;github.com&#x2F;mvdan&#x2F;github-actions-golang&#x2F;blob&#x2F;master&#x2F;README.md - name: Configure git for private modules run: | git config --global \ url.&quot;https:&#x2F;&#x2F;${{ secrets.GHUSER }}:${{ secrets.GHTOKEN }}@github.com&quot;.insteadOf \ &quot;https:&#x2F;&#x2F;github.com&quot; - name: Build ${{ env.NAME }} Command run: | GOOS=${{ matrix.GOOS }} \ GOARCH=${{ matrix.GOARCH }} \ go build -o ${{ env.NAME }} cmd&#x2F;main.go - name: Upload Release Asset - ${{ matrix.GOOS }} &#x2F; ${{ matrix.GOARCH }} uses: actions&#x2F;upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ github.event.release.upload_url }} asset_path: .&#x2F;${{ env.NAME }} asset_name: ${{ env.NAME }} asset_content_type: application&#x2F;octet-stream </code></pre> edit: code formatting