|
| 1 | +name: Publish to packages.smallstep.com |
| 2 | + |
| 3 | +# Independently publish packages to Red Hat (RPM) and Debian (DEB) repositories |
| 4 | +# without running a full release. Useful for: |
| 5 | +# - Re-importing packages after a failed/partial release |
| 6 | +# - Rebuilding packages from an existing tag |
| 7 | +# |
| 8 | +# Usage (CLI): |
| 9 | +# gh workflow run publish-packages.yml -f tag=v0.28.0 -f mode=import-only |
| 10 | +# gh workflow run publish-packages.yml -f tag=v0.28.0 -f mode=rebuild |
| 11 | + |
| 12 | +on: |
| 13 | + workflow_dispatch: |
| 14 | + inputs: |
| 15 | + tag: |
| 16 | + description: | |
| 17 | + Git tag to publish (e.g., v0.28.0). |
| 18 | + Pre-release tags (-rc) are blocked. |
| 19 | + required: true |
| 20 | + type: string |
| 21 | + mode: |
| 22 | + description: | |
| 23 | + import-only: Import existing packages from GCS (~30s) |
| 24 | + rebuild: Build packages, upload to GCS, then import (~5-10min) |
| 25 | + required: true |
| 26 | + type: choice |
| 27 | + options: |
| 28 | + - import-only |
| 29 | + - rebuild |
| 30 | + default: import-only |
| 31 | + |
| 32 | +jobs: |
| 33 | + publish: |
| 34 | + runs-on: ubuntu-latest |
| 35 | + permissions: |
| 36 | + id-token: write |
| 37 | + contents: read |
| 38 | + steps: |
| 39 | + - name: Validate tag (block pre-releases) |
| 40 | + run: | |
| 41 | + if [[ "${{ inputs.tag }}" == *"-rc"* ]]; then |
| 42 | + echo "::error::Pre-release tags (-rc) cannot be published to production repos" |
| 43 | + exit 1 |
| 44 | + fi |
| 45 | +
|
| 46 | + - name: Checkout |
| 47 | + uses: actions/checkout@v4 |
| 48 | + with: |
| 49 | + ref: ${{ inputs.tag }} |
| 50 | + fetch-depth: 0 |
| 51 | + |
| 52 | + - name: Extract version |
| 53 | + id: version |
| 54 | + run: echo "version=${TAG#v}" >> $GITHUB_OUTPUT |
| 55 | + env: |
| 56 | + TAG: ${{ inputs.tag }} |
| 57 | + |
| 58 | + - name: Authenticate to Google Cloud |
| 59 | + uses: google-github-actions/auth@v2 |
| 60 | + with: |
| 61 | + workload_identity_provider: ${{ secrets.GOOGLE_CLOUD_WORKLOAD_IDENTITY_PROVIDER }} |
| 62 | + service_account: ${{ secrets.GOOGLE_CLOUD_GITHUB_SERVICE_ACCOUNT }} |
| 63 | + |
| 64 | + - name: Set up Cloud SDK |
| 65 | + uses: google-github-actions/setup-gcloud@v2 |
| 66 | + with: |
| 67 | + project_id: ${{ secrets.GOOGLE_CLOUD_PACKAGES_PROJECT_ID }} |
| 68 | + |
| 69 | + # === REBUILD MODE ONLY === |
| 70 | + - name: Set up Go |
| 71 | + if: inputs.mode == 'rebuild' |
| 72 | + uses: actions/setup-go@v5 |
| 73 | + with: |
| 74 | + go-version: stable |
| 75 | + |
| 76 | + - name: Write GPG key |
| 77 | + if: inputs.mode == 'rebuild' |
| 78 | + run: echo "${{ secrets.GPG_PRIVATE_KEY }}" > "$GPG_PRIVATE_KEY_FILE" |
| 79 | + env: |
| 80 | + GPG_PRIVATE_KEY_FILE: "0x889B19391F774443-Certify.key" |
| 81 | + |
| 82 | + - name: Run GoReleaser (build packages only) |
| 83 | + if: inputs.mode == 'rebuild' |
| 84 | + uses: goreleaser/goreleaser-action@v6 |
| 85 | + with: |
| 86 | + distribution: goreleaser-pro |
| 87 | + version: "~> v2" |
| 88 | + args: release --clean --skip=announce,publish |
| 89 | + env: |
| 90 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 91 | + GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }} |
| 92 | + NFPM_PASSPHRASE: ${{ secrets.GPG_PRIVATE_KEY_PASSWORD }} |
| 93 | + GPG_PRIVATE_KEY_FILE: "0x889B19391F774443-Certify.key" |
| 94 | + |
| 95 | + - name: Upload packages to GCS |
| 96 | + if: inputs.mode == 'rebuild' |
| 97 | + run: | |
| 98 | + for pkg in dist/*.deb dist/*.rpm; do |
| 99 | + ./scripts/package-upload.sh "$pkg" step-cli ${{ steps.version.outputs.version }} |
| 100 | + done |
| 101 | +
|
| 102 | + # === BOTH MODES === |
| 103 | + - name: Import packages to Artifact Registry |
| 104 | + run: ./scripts/package-repo-import.sh step-cli ${{ steps.version.outputs.version }} |
| 105 | + env: |
| 106 | + IS_PRERELEASE: 'false' |
0 commit comments