Skip to content

Commit 3fd95b1

Browse files
committed
Initial commit.
0 parents  commit 3fd95b1

17 files changed

Lines changed: 1534 additions & 0 deletions

.github/workflows/build-push.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: build-push
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
paths:
9+
- Dockerfile
10+
- .github/workflows/build-push.yaml
11+
12+
jobs:
13+
run:
14+
uses: libops/.github/.github/workflows/build-push.yaml@main
15+
permissions:
16+
contents: read
17+
packages: write
18+
secrets: inherit
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
name: reusable-goreleaser
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
go-version:
7+
required: false
8+
type: string
9+
default: ">=1.25.8"
10+
goreleaser-args:
11+
required: false
12+
type: string
13+
default: "release --clean"
14+
publish-package-repo:
15+
required: false
16+
type: boolean
17+
default: false
18+
package-name:
19+
required: false
20+
type: string
21+
default: ""
22+
package-repo-prefix:
23+
required: false
24+
type: string
25+
default: ""
26+
package-repo-label:
27+
required: false
28+
type: string
29+
default: ""
30+
package-public-key-name:
31+
required: false
32+
type: string
33+
default: ""
34+
gcp-project:
35+
required: false
36+
type: string
37+
default: ""
38+
workload-identity-provider:
39+
required: false
40+
type: string
41+
default: ""
42+
service-account:
43+
required: false
44+
type: string
45+
default: ""
46+
gcs-bucket:
47+
required: false
48+
type: string
49+
default: ""
50+
aptly-gpg-key-id:
51+
required: false
52+
type: string
53+
default: ""
54+
aptly-gpg-private-key-secret:
55+
required: false
56+
type: string
57+
default: "aptly-gpg-private-key"
58+
aptly-gpg-passphrase-secret:
59+
required: false
60+
type: string
61+
default: "aptly-gpg-passphrase"
62+
63+
permissions:
64+
contents: write
65+
id-token: write
66+
67+
jobs:
68+
goreleaser:
69+
runs-on: ubuntu-24.04
70+
steps:
71+
- name: Checkout
72+
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
73+
with:
74+
fetch-depth: 0
75+
76+
- name: Set up Go
77+
uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6
78+
with:
79+
go-version: ${{ inputs.go-version }}
80+
81+
- name: Run GoReleaser
82+
uses: goreleaser/goreleaser-action@e435ccd777264be153ace6237001ef4d979d3a7a # v6
83+
with:
84+
distribution: goreleaser
85+
version: latest
86+
args: ${{ inputs.goreleaser-args }}
87+
env:
88+
GITHUB_TOKEN: ${{ secrets.HOMEBREW_REPO }}
89+
90+
- name: Authenticate to Google Cloud
91+
if: ${{ inputs.publish-package-repo }}
92+
uses: google-github-actions/auth@v2
93+
with:
94+
workload_identity_provider: ${{ inputs.workload-identity-provider }}
95+
service_account: ${{ inputs.service-account }}
96+
create_credentials_file: true
97+
98+
- name: Checkout Package Publisher
99+
if: ${{ inputs.publish-package-repo }}
100+
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
101+
with:
102+
repository: libops/terraform-linux-packages
103+
ref: main
104+
path: .libops-packages
105+
106+
- name: Publish Linux package repository
107+
if: ${{ inputs.publish-package-repo }}
108+
shell: bash
109+
working-directory: .libops-packages
110+
env:
111+
GH_TOKEN: ${{ github.token }}
112+
GCLOUD_PROJECT: ${{ inputs.gcp-project }}
113+
GCS_BUCKET: ${{ inputs.gcs-bucket }}
114+
APTLY_GPG_KEY_ID: ${{ inputs.aptly-gpg-key-id }}
115+
APTLY_GPG_PRIVATE_KEY_SECRET: ${{ inputs.aptly-gpg-private-key-secret }}
116+
APTLY_GPG_PASSPHRASE_SECRET: ${{ inputs.aptly-gpg-passphrase-secret }}
117+
run: |
118+
set -euo pipefail
119+
make package \
120+
GITHUB_REPOSITORY="${GITHUB_REPOSITORY}" \
121+
PACKAGE_NAME="${{ inputs.package-name }}" \
122+
GCS_BUCKET_PREFIX="${{ inputs.package-repo-prefix }}" \
123+
APTLY_LABEL="${{ inputs.package-repo-label }}" \
124+
APTLY_PUBLIC_KEY_NAME="${{ inputs.package-public-key-name }}" \
125+
RELEASE_VERSION="${GITHUB_REF_NAME}"
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
name: reusable-publish-package-repo
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
go-version:
7+
required: false
8+
type: string
9+
default: ">=1.25.8"
10+
gcp-project:
11+
required: true
12+
type: string
13+
workload-identity-provider:
14+
required: true
15+
type: string
16+
service-account:
17+
required: true
18+
type: string
19+
gcs-bucket:
20+
required: true
21+
type: string
22+
gcs-bucket-prefix:
23+
required: false
24+
type: string
25+
default: ""
26+
aptly-gpg-key-id:
27+
required: true
28+
type: string
29+
aptly-gpg-private-key-secret:
30+
required: false
31+
type: string
32+
default: "aptly-gpg-private-key"
33+
aptly-gpg-passphrase-secret:
34+
required: false
35+
type: string
36+
default: "aptly-gpg-passphrase"
37+
aptly-distributions:
38+
required: false
39+
type: string
40+
default: "bookworm"
41+
aptly-component:
42+
required: false
43+
type: string
44+
default: "main"
45+
aptly-architectures:
46+
required: false
47+
type: string
48+
default: "amd64,arm64"
49+
aptly-publish-prefix:
50+
required: false
51+
type: string
52+
default: "."
53+
aptly-origin:
54+
required: false
55+
type: string
56+
default: "libops"
57+
aptly-label:
58+
required: false
59+
type: string
60+
default: ""
61+
aptly-public-key-name:
62+
required: false
63+
type: string
64+
default: ""
65+
rpm-repository-path:
66+
required: false
67+
type: string
68+
default: "rpm"
69+
dist-dir:
70+
required: false
71+
type: string
72+
default: "dist"
73+
74+
permissions:
75+
contents: read
76+
id-token: write
77+
78+
jobs:
79+
publish-package-repo:
80+
runs-on: ubuntu-24.04
81+
steps:
82+
- name: Checkout
83+
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
84+
with:
85+
fetch-depth: 0
86+
87+
- name: Checkout Publishing Workflows
88+
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
89+
with:
90+
repository: libops/terraform-linux-packages
91+
ref: main
92+
path: .libops-packages
93+
94+
- name: Set up Go
95+
uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6
96+
with:
97+
go-version: ${{ inputs.go-version }}
98+
99+
- name: Run GoReleaser
100+
uses: goreleaser/goreleaser-action@e435ccd777264be153ace6237001ef4d979d3a7a # v6
101+
with:
102+
distribution: goreleaser
103+
version: latest
104+
args: release --clean --skip=publish
105+
env:
106+
GITHUB_TOKEN: ${{ secrets.HOMEBREW_REPO }}
107+
108+
- name: Authenticate to Google Cloud
109+
uses: google-github-actions/auth@v2
110+
with:
111+
workload_identity_provider: ${{ inputs.workload-identity-provider }}
112+
service_account: ${{ inputs.service-account }}
113+
114+
- name: Set up gcloud
115+
uses: google-github-actions/setup-gcloud@v2
116+
117+
- name: Install Package Repository Tooling
118+
run: sudo apt-get update && sudo apt-get install -y aptly createrepo-c gnupg
119+
120+
- name: Publish Linux package repository
121+
shell: bash
122+
env:
123+
GCLOUD_PROJECT: ${{ inputs.gcp-project }}
124+
GCS_BUCKET: ${{ inputs.gcs-bucket }}
125+
GCS_BUCKET_PREFIX: ${{ inputs.gcs-bucket-prefix }}
126+
PACKAGE_NAME: ${{ github.event.repository.name }}
127+
APTLY_GPG_KEY_ID: ${{ inputs.aptly-gpg-key-id }}
128+
APTLY_GPG_PRIVATE_KEY_SECRET: ${{ inputs.aptly-gpg-private-key-secret }}
129+
APTLY_GPG_PASSPHRASE_SECRET: ${{ inputs.aptly-gpg-passphrase-secret }}
130+
APTLY_DISTRIBUTIONS: ${{ inputs.aptly-distributions }}
131+
APTLY_COMPONENT: ${{ inputs.aptly-component }}
132+
APTLY_ARCHITECTURES: ${{ inputs.aptly-architectures }}
133+
APTLY_PUBLISH_PREFIX: ${{ inputs.aptly-publish-prefix }}
134+
APTLY_ORIGIN: ${{ inputs.aptly-origin }}
135+
APTLY_LABEL_INPUT: ${{ inputs.aptly-label }}
136+
APTLY_PUBLIC_KEY_NAME_INPUT: ${{ inputs.aptly-public-key-name }}
137+
RPM_REPOSITORY_PATH: ${{ inputs.rpm-repository-path }}
138+
DIST_DIR: ${{ github.workspace }}/${{ inputs.dist-dir }}
139+
PACKAGE_REPO_STAGE_DIR: ${{ runner.temp }}/package-repository
140+
APTLY_ROOT_DIR: ${{ runner.temp }}/aptly
141+
GNUPGHOME: ${{ runner.temp }}/gnupg
142+
run: |
143+
set -euo pipefail
144+
if [ -n "${APTLY_LABEL_INPUT:-}" ]; then
145+
export APTLY_LABEL="$APTLY_LABEL_INPUT"
146+
fi
147+
if [ -n "${APTLY_PUBLIC_KEY_NAME_INPUT:-}" ]; then
148+
export APTLY_PUBLIC_KEY_NAME="$APTLY_PUBLIC_KEY_NAME_INPUT"
149+
fi
150+
/bin/bash "${GITHUB_WORKSPACE}/.libops-packages/scripts/publish-package-repo.sh"

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
terraform.tfvars
2+
.dist/
3+
.out/

Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FROM gcr.io/google.com/cloudsdktool/google-cloud-cli:slim
2+
3+
RUN apt-get update \
4+
&& apt-get install -y --no-install-recommends aptly createrepo-c gnupg ca-certificates \
5+
&& rm -rf /var/lib/apt/lists/*

0 commit comments

Comments
 (0)