|
| 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" |
0 commit comments