Skip to content

Commit

Permalink
tech: update release and prerelease workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
sylviamoss committed Feb 17, 2024
1 parent 84adeeb commit e8a0a77
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 28 deletions.
23 changes: 7 additions & 16 deletions .github/workflows/prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,21 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Unshallow
run: git fetch --prune --unshallow
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}

- name: Setup Go
uses: actions/setup-go@v2
uses: actions/setup-go@v5
with:
cache: true
go-version-file: 'go.mod'
cache-dependency-path: go.sum

- name: Configure Git
env:
TOKEN: ${{ secrets.HCP_SDK_PIPELINE_TOKEN }}
TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global advice.detachedHead false
git config --global url."https://${TOKEN}:[email protected]/".insteadOf "https://github.com/"
Expand Down Expand Up @@ -85,19 +85,10 @@ jobs:
echo "New Version will be: $NEW_VERSION"
echo "## Updating ${CURRENT_VERSION} to ${NEW_VERSION}" >> $GITHUB_STEP_SUMMARY
echo "## Diff from Prerelease tasks" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`diff" >> $GITHUB_STEP_SUMMARY
git diff @{upstream} @ >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
echo "Diff from Prerelease tasks:"
git diff @{upstream} @
- name: Release New Version
if: success() && github.ref_name == 'main' && steps.changes.outputs.HAS_CHANGES == 'true' && ${{ !inputs.skip-release }}
if: ${{ success() && github.ref_name == 'master' && steps.changes.outputs.HAS_CHANGES == 'true' && !inputs.skip-release }}
run: |
git tag -a ${NEW_VERSION} -m "New version ${NEW_VERSION}"
echo "Git configuration:"
git config -l
echo "Pushing new tag to remote, which will trigger the Release workflow"
git push --tags
31 changes: 20 additions & 11 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,44 @@
# This GitHub action can publish assets for release when a tag is created.
name: release

on:
pull_request:
push:
# run only against tags
tags:
- 'v*'
- "*"

permissions:
contents: write

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Unshallow
run: git fetch --prune --unshallow
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@v4
with:
cache: true
go-version-file: 'go.mod'
cache-dependency-path: go.sum

- name: Import GPG key
id: import_gpg
uses: paultyng/ghaction-import-gpg@v2.1.0
uses: crazy-max/ghaction-import-gpg@v6
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
PASSPHRASE: ${{ secrets.PASSPHRASE }}
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.PASSPHRASE }}

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
uses: goreleaser/goreleaser-action@v5
with:
version: latest
args: release --rm-dist
args: release --clean
env:
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3 changes: 2 additions & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ checksum:
algorithm: sha256
signs:
- artifacts: checksum
cmd: gpg2
args:
- "--batch"
- "--local-user"
- "-u"
- "{{ .Env.GPG_FINGERPRINT }}"
- "--output"
- "${signature}"
Expand Down

0 comments on commit e8a0a77

Please sign in to comment.