Skip to content

Commit

Permalink
Merge pull request #99 from k1LoW/use-tagpr
Browse files Browse the repository at this point in the history
Fix build pipeline
  • Loading branch information
k1LoW authored Nov 4, 2022
2 parents aeb6858 + da8b034 commit 08913d4
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 42 deletions.
91 changes: 91 additions & 0 deletions .github/workflows/tagpr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: tagpr
on:
push:
branches:
- main

jobs:
tagpr:
runs-on: ubuntu-latest
outputs:
tagpr-tag: ${{ steps.run-tagpr.outputs.tag }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Check out source code
uses: actions/checkout@v3

- id: run-tagpr
name: Run tagpr
uses: Songmu/tagpr@v1

release:
needs: tagpr
if: needs.tagpr.outputs.tagpr-tag != ''
runs-on: macos-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Check out source code
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup
run: |
brew uninstall [email protected]
brew install go
brew install goreleaser
brew install messense/macos-cross-toolchains/x86_64-unknown-linux-gnu
- name: Release
run: |
make release
dockerimage:
needs: tagpr
if: needs.tagpr.outputs.tagpr-tag != ''
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Check out source code
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Get latest version
id: latest_version
run: |
echo -n 'version=' > $GITHUB_OUTPUT
gh release list --limit 1 | cut -f 1 >> $GITHUB_OUTPUT
cat $GITHUB_OUTPUT
- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to ghcr.io
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
file: Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: |
ghcr.io/k1low/ndiag:latest
ghcr.io/k1low/ndiag:${{ steps.latest_version.outputs.version }}
labels: |
org.opencontainers.image.name=ndiag
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.version=${{ steps.latest_version.outputs.version }}
org.opencontainers.image.source=https://github.com/k1LoW/ndiag
37 changes: 1 addition & 36 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ builds:
- -extldflags '-static'
env:
- CGO_ENABLED=1
- CC=/usr/local/bin/x86_64-linux-musl-cc # brew install FiloSottile/musl-cross/musl-cross
- CC=x86_64-unknown-linux-gnu-gcc # brew install messense/macos-cross-toolchains/x86_64-unknown-linux-gnu
goos:
- linux
goarch:
Expand All @@ -64,41 +64,6 @@ changelog:
exclude:
- '^docs:'
- '^test:'
dockers:
-
goos: linux
goarch: amd64
image_templates:
- 'ghcr.io/k1low/ndiag:v{{ .Version }}'
- 'ghcr.io/k1low/ndiag:latest'
dockerfile: Dockerfile
build_flag_templates:
- "--pull"
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.name={{.ProjectName}}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.version={{.Version}}"
- "--label=org.opencontainers.image.source=https://github.com/k1LoW/ndiag"
extra_files:
- scripts/entrypoint.sh
brews:
-
name: ndiag
tap:
owner: k1LoW
name: homebrew-tap
commit_author:
name: k1LoW
email: [email protected]
homepage: https://github.com/k1LoW/ndiag
description: 'ndiag is a high-level architecture diagramming/documentation tool.'
license: MIT
install: |
system './ndiag', 'completion', 'bash', '--out', 'ndiag.bash'
system './ndiag', 'completion', 'zsh', '--out', 'ndiag.zsh'
bin.install 'ndiag'
bash_completion.install 'ndiag.bash' => 'ndiag'
zsh_completion.install 'ndiag.zsh' => '_ndiag'
nfpms:
-
id: ndiag-nfpms
Expand Down
20 changes: 14 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
FROM alpine:3.13
FROM golang:1-bullseye AS builder

RUN apk add --no-cache bash curl git
WORKDIR /workdir/
COPY . /workdir/

RUN apt-get update

RUN update-ca-certificates

RUN make build

FROM debian:bullseye-slim

COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /workdir/ndiag ./usr/bin

ENTRYPOINT ["/entrypoint.sh"]
CMD [ "-h" ]

COPY scripts/entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

COPY ndiag_*.apk /tmp/
RUN apk add --allow-untrusted /tmp/ndiag_*.apk

0 comments on commit 08913d4

Please sign in to comment.