|
| 1 | +name: Manually Create Full Release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + tag: |
| 7 | + description: 'The tag to create, make sure to select the correct branch.' |
| 8 | + required: true |
| 9 | + sha: |
| 10 | + description: 'The commit SHA to create the tag from, defaults to HEAD of the selected branch.' |
| 11 | + required: false |
| 12 | + |
| 13 | +permissions: |
| 14 | + contents: write |
| 15 | + id-token: write |
| 16 | + actions: read |
| 17 | + |
| 18 | +jobs: |
| 19 | + release: |
| 20 | + runs-on: ubuntu-latest |
| 21 | + steps: |
| 22 | + - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 https://github.com/actions/checkout |
| 23 | + with: |
| 24 | + fetch-depth: 0 |
| 25 | + - name: Create and Push Tag with Git |
| 26 | + id: create-push-tag |
| 27 | + env: |
| 28 | + TAG: ${{ inputs.tag }} |
| 29 | + SHA: ${{ inputs.sha }} |
| 30 | + run: | |
| 31 | + git config user.name "${{ github.actor }}" |
| 32 | + git config user.email "${{ github.actor }}@users.noreply.github.com" |
| 33 | + if [ -n "${SHA}" ]; then |
| 34 | + git checkout "$SHA" |
| 35 | + fi |
| 36 | + git tag "$TAG" -m "Release $TAG" |
| 37 | + git push origin "$TAG" |
| 38 | + - name: retrieve GPG Credentials |
| 39 | + id: retrieve-gpg-credentials |
| 40 | + uses: rancher-eio/read-vault-secrets@main |
| 41 | + with: |
| 42 | + secrets: | |
| 43 | + secret/data/github/repo/${{ github.repository }}/signing/gpg passphrase | GPG_PASSPHRASE ; |
| 44 | + secret/data/github/repo/${{ github.repository }}/signing/gpg privateKeyId | GPG_KEY_ID ; |
| 45 | + secret/data/github/repo/${{ github.repository }}/signing/gpg privateKey | GPG_KEY |
| 46 | + - name: import_gpg_key |
| 47 | + id: import-gpg-key |
| 48 | + env: |
| 49 | + GPG_PASSPHRASE: ${{ env.GPG_PASSPHRASE }} |
| 50 | + GPG_KEY_ID: ${{ env.GPG_KEY_ID }} |
| 51 | + GPG_KEY: ${{ env.GPG_KEY }} |
| 52 | + run: | |
| 53 | + cleanup() { |
| 54 | + # clear history just in case |
| 55 | + history -c |
| 56 | + } |
| 57 | + trap cleanup EXIT TERM |
| 58 | +
|
| 59 | + # sanitize variables |
| 60 | + if [ -z "${GPG_PASSPHRASE}" ]; then echo "gpg passphrase empty"; exit 1; fi |
| 61 | + if [ -z "${GPG_KEY_ID}" ]; then echo "key id empty"; exit 1; fi |
| 62 | + if [ -z "${GPG_KEY}" ]; then echo "key contents empty"; exit 1; fi |
| 63 | +
|
| 64 | + echo "Importing gpg key" |
| 65 | + echo "${GPG_KEY}" | gpg --import --batch > /dev/null || { echo "Failed to import GPG key"; exit 1; } |
| 66 | + - name: Run GoReleaser |
| 67 | + uses: goreleaser/goreleaser-action@e435ccd777264be153ace6237001ef4d979d3a7a # v6.4.0 https://github.com/goreleaser/goreleaser-action |
| 68 | + with: |
| 69 | + args: release --clean --config .goreleaser_rc.yml |
| 70 | + env: |
| 71 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 72 | + GPG_KEY_ID: ${{ env.GPG_KEY_ID }} |
| 73 | + GPG_PASSPHRASE: ${{ env.GPG_PASSPHRASE }} |
0 commit comments