test: add branch push trigger for smoke test #1
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release | |
| on: | |
| pull_request: | |
| types: [closed] | |
| branches: [master] | |
| push: | |
| branches: [add-secretsmanager-support] | |
| jobs: | |
| release: | |
| if: github.event.pull_request.merged == true | |
| name: Version, release, and publish | |
| runs-on: ubuntu-latest-large | |
| permissions: | |
| contents: write | |
| pull-requests: read | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| with: | |
| fetch-depth: 0 | |
| - name: Compute next version | |
| id: version | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| REPO: ${{ github.repository }} | |
| PR_NUMBER: ${{ github.event.pull_request.number }} | |
| MERGE_SHA: ${{ github.event.pull_request.merge_commit_sha }} | |
| DEFAULT_BUMP: patch | |
| MAJOR_LABEL: release:major | |
| MINOR_LABEL: release:minor | |
| SKIP_LABEL: release:skip | |
| INITIAL_VERSION: v0.1.0 | |
| run: | | |
| set -euo pipefail | |
| labels=$(gh api "repos/${REPO}/issues/${PR_NUMBER}/labels" --jq '.[].name') | |
| has_label() { echo "$labels" | grep -Fxq "$1"; } | |
| if has_label "$SKIP_LABEL"; then | |
| echo "PR carries '$SKIP_LABEL' — skipping release." | |
| echo "skip=true" >> "$GITHUB_OUTPUT" | |
| exit 0 | |
| fi | |
| if has_label "$MAJOR_LABEL"; then bump=major; | |
| elif has_label "$MINOR_LABEL"; then bump=minor; | |
| else bump="$DEFAULT_BUMP"; fi | |
| latest=$(git tag --list 'v*' --sort=-v:refname | head -n1) | |
| [ -n "$latest" ] || latest="$INITIAL_VERSION" | |
| ver="${latest#v}" | |
| IFS='.' read -r major minor patch <<< "$ver" | |
| case "$bump" in | |
| major) new="v$((major + 1)).0.0" ;; | |
| minor) new="v${major}.$((minor + 1)).0" ;; | |
| patch) new="v${major}.${minor}.$((patch + 1))" ;; | |
| esac | |
| echo "version=${new}" >> "$GITHUB_OUTPUT" | |
| echo "skip=false" >> "$GITHUB_OUTPUT" | |
| echo "Computed version: ${new} (bump: ${bump})" | |
| - name: Build binary | |
| if: steps.version.outputs.skip == 'false' | |
| env: | |
| GOPROXY: "https://go.artifacts.twilio.com/artifactory/api/go/virtual-go-thirdparty" | |
| GOPRIVATE: "github.com/twilio-internal,github.com/segmentio,github.com/sendgrid,github.com/sendgrid-ops,github.com/sendgrid-dev,github.com/zipwhip,code.hq.twilio.com" | |
| run: | | |
| CGO_ENABLED=0 go build -mod=vendor -a -tags netgo \ | |
| -ldflags "-w -X 'main.version=${{ steps.version.outputs.version }}' -X 'main.builtAt=${{ github.event.pull_request.merged_at }}' -X 'main.gitHash=${{ github.event.pull_request.merge_commit_sha }}' -extldflags -static" \ | |
| -o aws-env \ | |
| ./cmd/aws-env | |
| - name: Create GitHub Release | |
| if: steps.version.outputs.skip == 'false' | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| MERGE_SHA: ${{ github.event.pull_request.merge_commit_sha }} | |
| VERSION: ${{ steps.version.outputs.version }} | |
| run: | | |
| test -f aws-env || { echo "ERROR: aws-env binary not found — make artifact may have failed"; exit 1; } | |
| gh release create "$VERSION" \ | |
| aws-env \ | |
| --target "$MERGE_SHA" \ | |
| --title "$VERSION" \ | |
| --generate-notes \ | |
| --latest |