Skip to content
This repository has been archived by the owner on Nov 22, 2022. It is now read-only.

chore(packaging): glab docker images #746

Merged
merged 3 commits into from
Jun 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions .github/workflows/build_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,20 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Checkout
uses: actions/checkout@v2
with:
ref: trunk
fetch-depth: 0
- run: |
- name: Get Latest Version Tag
id: get_version
uses: battila7/get-version-action@v2

- name: Update docs
run: |
git config user.name github-actions
git config user.email github-actions@github.com
make gen-docs
git add docs
git commit -m "docs(update): latest" || echo "No document(s) updates found!"
git commit -m "docs(update): ${{ steps.get_version.outputs.version }}" || echo "No document(s) updates found!"
git push
51 changes: 47 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,57 @@ name: goreleaser

on:
push:
branches:
- 'trunk'
tags:
- "*"
- "v*"
pull_request:

jobs:
goreleaser:
runs-on: ubuntu-latest
env:
DOCKER_CLI_EXPERIMENTAL: "enabled"
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set up QEMU
uses: docker/setup-qemu-action@v1

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

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.14
go-version: 1.16

- name: Cache Go modules
uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-

- name: Login to Docker Hub
if: startsWith(github.ref, 'refs/tags/v')
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Login to GitHub Container Registry
if: startsWith(github.ref, 'refs/tags/v')
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.PS_TOKEN }}

- name: Generate changelog
if: startsWith(github.ref, 'refs/tags/v')
run: |
echo "GORELEASER_CURRENT_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
git fetch --unshallow
Expand All @@ -27,20 +62,27 @@ jobs:
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: release --rm-dist --release-notes=CHANGELOG.md
install-only: true
env:
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
run: |
if [[ $GITHUB_REF == refs/tags/v* ]]; then
goreleaser release --rm-dist --release-notes=CHANGELOG.md
elif [[ $GITHUB_REF == refs/heads/master ]]; then
goreleaser --snapshot
fi

- name: Bump Homebrew formula
uses: mislav/bump-homebrew-formula-action@v1
if: "!contains(github.ref, '-')" # skip prereleases
if: "!contains(github.ref, '-') && startsWith(github.ref, 'refs/tags/v')" # skip prereleases and run on tags
with:
formula-name: glab
env:
COMMITTER_TOKEN: ${{ secrets.PS_TOKEN }}

- name: Move project cards
continue-on-error: true
if: startsWith(github.ref, 'refs/tags/v')
env:
GITHUB_TOKEN: ${{secrets.BOT_TOKEN}}
PENDING_RELEASE_COLUMN: 11177289
Expand All @@ -57,6 +99,7 @@ jobs:
exe-installer:
needs: goreleaser
runs-on: windows-latest
if: startsWith(github.ref, 'refs/tags/v')

steps:
- name: Checkout
Expand Down
32 changes: 32 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ release:
before:
hooks:
- go mod tidy
- make manpage

builds:
- <<: &build_defaults
Expand All @@ -29,6 +30,33 @@ builds:
goos: [windows]
goarch: [386, amd64]

dockers:
- image_templates:
- 'profclems/glab:{{ .Tag }}'
- 'ghcr.io/profclems/glab:{{ .Tag }}'
dockerfile: Dockerfile
use_buildx: true
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={{.GitURL}}"
- "--platform=linux/amd64"
extra_files:
- scripts/entrypoint.sh
docker_manifests:
- name_template: 'profclems/glab:{{ .Tag }}'
image_templates:
- 'profclems/glab:{{ .Tag }}'
- name_template: 'profclems/glab:latest'
image_templates:
- 'profclems/glab:{{ .Tag }}'
- name_template: 'ghcr.io/profclems/glab:latest'
image_templates:
- 'ghcr.io/profclems/glab:{{ .Tag }}'

archives:
- id: nix
builds: [macos, linux]
Expand Down Expand Up @@ -71,13 +99,17 @@ nfpms:
description: An open source gitlab cli tool
license: MIT
formats:
- apk
- deb
- rpm
dependencies:
- git
# Override default /usr/local/bin destination for binaries
# Since glab is already archived in the bin directory it would install in /usr/bin/glab
bindir: /usr
contents:
- src: "./share/man/man1/glab*.1"
dst: "/usr/share/man/man1"

checksum:
name_template: 'checksums.txt'
Expand Down
18 changes: 18 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM alpine:latest

RUN apk add --no-cache bash \
curl \
docker-cli \
git \
mercurial \
make \
build-base

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

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

COPY glab_*.apk /tmp/
RUN apk add --allow-untrusted /tmp/glab_*.apk
24 changes: 24 additions & 0 deletions scripts/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash

if [ -n "$DOCKER_USERNAME" ] && [ -n "$DOCKER_PASSWORD" ]; then
echo "Login to the docker..."
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin "$DOCKER_REGISTRY"
fi

# Workaround for github actions when access to different repositories is needed.
# Github actions provides a GITHUB_TOKEN secret that can only access the current
# repository and you cannot configure it's value.
# Access to different repositories is needed by brew for example.

if [ -n "$PS_TOKEN" ] ; then
export GITHUB_TOKEN=$PS_TOKEN
fi

if [ -n "$GITHUB_TOKEN" ]; then
# Log into GitHub package registry
echo "$GITHUB_TOKEN" | docker login docker.pkg.github.com -u docker --password-stdin
echo "$GITHUB_TOKEN" | docker login ghcr.io -u docker --password-stdin
fi

# shellcheck disable=SC2068
glab $@