Skip to content

Commit

Permalink
Improve release process
Browse files Browse the repository at this point in the history
  • Loading branch information
jriguera committed Aug 28, 2024
1 parent 7d95c14 commit 6237ad3
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 7 deletions.
69 changes: 63 additions & 6 deletions .github/workflows/release-artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ on:
push:
branches:
- "main"
tags:
- '**'

env:
# Default image for the Chart
Expand All @@ -20,6 +22,7 @@ jobs:
outputs:
artifact: ${{ steps.artifact.outputs.artifact-id }}
version: ${{ steps.versions.outputs.version }}
buildname: ${{ steps.versions.outputs.build-name }}
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down Expand Up @@ -54,7 +57,7 @@ jobs:
id: artifact
uses: actions/upload-artifact@v4
with:
name: otelcol-${{ steps.versions.outputs.version }}
name: "otelcol-${{ steps.versions.outputs.version }}_linux_amd64"
retention-days: 1
path: "${{ steps.versions.outputs.build-path }}/${{ steps.versions.outputs.build-name }}"
if-no-files-found: error
Expand All @@ -66,17 +69,19 @@ jobs:
packages: write
needs:
- compile
if: ${{ github.event_name != 'pull_request' }}
if: ${{ (github.event_name != 'pull_request') && (startsWith(github.ref, 'refs/tags/')) }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/download-artifact@v4
- name: Download artifact
id: artifact
uses: actions/download-artifact@v4
with:
name: otelcol-${{ needs.compile.outputs.version }}
name: "otelcol-${{ needs.compile.outputs.version }}_linux_amd64"
path: otelcol-dev

- name: Get metadata for Docker image
Expand All @@ -97,13 +102,65 @@ jobs:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}


- name: Build and export to Docker
uses: docker/build-push-action@v6
with:
context: ${{ env.DOCKER_BUILD_DIR }}
build-args:
- "OTEL_BIN=${{ steps.artifact.outputs.download-path }}/${{ needs.compile.outputs.build-name }}"
load: true
tags: otelcol

# - name: Test
# run: |
# docker run --rm otelcol

- name: Build and push to Github Packages
uses: docker/build-push-action@v5
uses: docker/build-push-action@v6
with:
context: ${{ env.DOCKER_BUILD_DIR }}
push: ${{ github.event_name != 'pull_request' }}
build-args:
- "OTEL_BIN=${{ steps.artifact.outputs.download-path }}/${{ needs.compile.outputs.build-name }}"
tags: |
${{ steps.meta.outputs.tags }}
${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_NAME }}:${{ needs.compile.outputs.version }}
labels: ${{ steps.meta.outputs.labels }}

release:
permissions:
contents: write
packages: read
needs:
- compile
- build-image
if: ${{ (github.event_name != 'pull_request') && (startsWith(github.ref, 'refs/tags/')) }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Get artifact
id: artifact
uses: actions/download-artifact@v4
with:
name: "otelcol-${{ needs.compile.outputs.version }}_linux_amd64"
path: otelcol-dev

- name: Get list of artifacts
run: |
cd "${{ steps.artifact.outputs.download-path }}"
mkdir "otelcol-custom_${{ needs.compile.outputs.version }}"
cp "${{ needs.compile.outputs.build-name }}" "otelcol-custom_${{ needs.compile.outputs.version }}/otelcol-custom_${{ needs.compile.outputs.version }}_linux_amd64"
mv "${{ needs.compile.outputs.build-name }}" "otelcol-custom_${{ needs.compile.outputs.version }}_linux_amd64.bin"
tar zcvf "otelcol-custom_${{ needs.compile.outputs.version }}.tgz" "otelcol-custom_${{ needs.compile.outputs.version }}"
rm "otelcol-custom_${{ needs.compile.outputs.version }}"
- name: Create a Release
uses: softprops/action-gh-release@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
files: "${{ steps.artifact.outputs.download-path }}/*"
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ RUN apk --update add ca-certificates
FROM debian:12-slim

ARG USER_UID=10001
ARG OTEL_BIN=otelcol-dev/otelcol-dev
USER ${USER_UID}

COPY --from=certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --chmod=755 otelcol-dev/otelcol-dev /otelcol-contrib
COPY --chmod=755 ${OTEL_BIN} /otelcol-contrib
COPY otelcol-contrib.yaml /etc/otelcol-contrib/config.yaml
ENTRYPOINT ["/otelcol-contrib"]
CMD ["--config", "/etc/otelcol-contrib/config.yaml"]
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,11 @@ If you want to get to your own custom collector compiled or updated:
```
With this configuration the collector will scrape its own metrics.
# Create a new release (with binaries)
Releases are managed by the GH Action workflow. Please commit all changes and then push an annotated tag to the repository.
```
git tag -a v<version> -m "<comment>"
git push --tags
```

0 comments on commit 6237ad3

Please sign in to comment.