platform: linux

image_resource:
  type: docker-image
  source:
    repository: cfcli/cli-package

inputs:
- name: certificates

params:
  AWS_ACCESS_KEY_ID:
  AWS_SECRET_ACCESS_KEY:
  GPG_KEY_LOCATION:

run:
  path: bash
  args:
  - -c
  - |
    set -e
    cat<<EOF >sign-repodata

    #!/usr/bin/expect -f
    spawn gpg --detach-sign --armor repodata/repomd.xml
    expect -exact "Enter pass phrase: "
    send -- "\r"
    expect eof
    EOF
    chmod 700 sign-repodata

    mkdir gpg-dir
    export GNUPGHOME=$PWD/gpg-dir
    chmod 700 $GNUPGHOME
    trap "rm -rf $GNUPGHOME" 0

    gpg --import certificates/$GPG_KEY_LOCATION

    aws s3 sync \
      --exclude "*" \
      --include "releases/*/*installer*.rpm" \
      s3://cf-cli-releases \
      .

    #  aws s3 sync \
    #    --exclude "*" \
    #    --include "releases/*/*installer*.rpm" \
    #    s3://v7-cf-cli-releases \
    #    .

    createrepo -s sha .
    # ./sign-repodata

    aws s3 sync \
      --delete \
      repodata \
      s3://cf-cli-rpm-repo/repodata

platform: linux

image_resource:
  type: docker-image
  source:
    repository: cfcli/cli-package

inputs:
- name: certificates

params:
  AWS_ACCESS_KEY_ID:
  AWS_SECRET_ACCESS_KEY:
  GPG_KEY_LOCATION:

run:
  path: bash
  args:
  - -c
  - |
    set -e
    cat<<EOF >sign-repodata

    #!/usr/bin/expect -f
    spawn gpg --detach-sign --armor repodata/repomd.xml
    expect -exact "Enter pass phrase: "
    send -- "\r"
    expect eof
    EOF
    chmod 700 sign-repodata

    mkdir gpg-dir
    export GNUPGHOME=$PWD/gpg-dir
    chmod 700 $GNUPGHOME
    trap "rm -rf $GNUPGHOME" 0

    gpg --import certificates/$GPG_KEY_LOCATION

    aws s3 sync \
      --exclude "*" \
      --include "releases/*/*installer*.rpm" \
      s3://cf-cli-releases \
      .

    aws s3 sync \
      --exclude "*" \
      --include "releases/*/*installer*.rpm" \
      s3://v7-cf-cli-releases \
      .

    createrepo -s sha .
    # ./sign-repodata

    aws s3 sync \
      --delete \
      repodata \
      s3://cf-cli-rpm-repo/repodata

Revert "Comment-out the v7-cf-cli-releases for rpm repo"
Revert "Comment-out the v7-cf-cli-releases for rpm repo"

This reverts commit 9dcf38b7ef3a59227afddf55fcb976924671f2bb.

Prior to the recent work to complete our V7 release pipelines, old
V7 .rpm files were being tagged with V6 version numbers and uploaded
to an S3 bucket. When we pulled in the *.rpm files for both V6 and V7
with this pipeline job (intending to release 7.0.0-beta.24), we pulled
in the mis-tagged V7 .rpm files (beta.1 - beta.23). This resulted in
confusingly-versioned rpm packages named 'cf7-cli' (the old ones had V6
versions but V7 code).

We renamed the files in the S3 bucket from *.rpm to *.rpm.bak, to
preserve them but make sure this task doesn't pull them in. We never
intended for these to be released on rpm anyway.

Going forward, only V7 versions 7.0.0-beta.24 and above will be
available on rpm.

[#166481406]

Co-authored-by: Reid Mitchell <15b84f3bcf1e0a1a99817cc9360cedc980d7c5b6@pivotal.io>
