feat: docker release #15
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: Release Workflow | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
permissions: | |
contents: write | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: '1.23' | |
- name: Install GoReleaser | |
run: go install github.com/goreleaser/goreleaser@latest | |
- name: Check version | |
run: | | |
VERSION=$(cat VERSION.txt) | |
echo "version=$VERSION" >> $GITHUB_ENV | |
echo "Version: $VERSION" | |
- name: Run build using goreleaser on local | |
run: goreleaser release --snapshot --skip=publish --clean | |
- name: Create Tag | |
if: | | |
(github.event_name == 'push' && github.ref == 'refs/heads/main') || | |
(github.event_name == 'pull_request' && | |
github.event.action == 'closed' && | |
github.event.pull_request.merged == true && | |
github.event.pull_request.base.ref == 'main') | |
run: | | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git config --global user.name "github-actions[bot]" | |
git tag "v${{ env.version }}" | |
git push origin "v${{ env.version }}" | |
- name: Run GoReleaser Release | |
if: | | |
(github.event_name == 'push' && github.ref == 'refs/heads/main') || | |
(github.event_name == 'pull_request' && | |
github.event.action == 'closed' && | |
github.event.pull_request.merged == true && | |
github.event.pull_request.base.ref == 'main') | |
run: | | |
export GORELEASER_CURRENT_TAG="v${{ env.version }}" | |
export GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} | |
goreleaser release --clean --rm-dist | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Run GoReleaser Docker Push | |
if: | | |
(github.event_name == 'push' && github.ref == 'refs/heads/main') || | |
(github.event_name == 'pull_request' && | |
github.event.action == 'closed' && | |
github.event.pull_request.merged == true && | |
github.event.pull_request.base.ref == 'main') | |
run: | | |
export GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} | |
goreleaser release --rm-dist --skip-publish --snapshot | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build Docker images | |
if: | | |
(github.event_name == 'push' && github.ref == 'refs/heads/main') || | |
(github.event_name == 'pull_request' && | |
github.event.action == 'closed' && | |
github.event.pull_request.merged == true && | |
github.event.pull_request.base.ref == 'main') | |
run: | | |
gh release download --repo SentinalFS/file-monitor --clobber --pattern "monitor.bpf.o" | |
docker buildx build \ | |
--platform linux/amd64,linux/arm64 \ | |
--file Dockerfile \ | |
--push \ | |
-t siddh34/go-ebpf-logger:latest \ | |
-f Dockerfile64.amd64 . | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }} | |
DOCKER_BUILDKIT: 1 |