cli-release #294
This file contains 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: cli-release | |
# Releases the Devbox CLI | |
concurrency: cli-release | |
on: | |
# Build/Release on demand | |
workflow_dispatch: | |
inputs: | |
create_edge_release: | |
description: "Create edge release?" | |
required: false | |
default: false | |
type: boolean | |
schedule: | |
- cron: "45 8 * * 4" # Create edge weekly on Thursdays. | |
push: | |
tags: | |
- "*" # Tags that trigger a new release version | |
permissions: | |
contents: write | |
pull-requests: read | |
id-token: write # Needed for aws-actions/configure-aws-credentials@v1 | |
jobs: | |
tests: | |
uses: ./.github/workflows/cli-tests.yaml | |
report-test-failures: | |
runs-on: ubuntu-latest | |
needs: tests | |
if: failure() || cancelled() | |
steps: | |
- name: Notify jetpack.io slack of release status (only if tests fail) | |
id: slack | |
uses: slackapi/[email protected] | |
with: | |
payload: | | |
{ | |
"status": "test ${{ needs.tests.result }}" | |
} | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_CLI_RELEASE_WEBHOOK_URL }} | |
edge: | |
runs-on: ubuntu-latest | |
environment: release | |
needs: tests | |
if: ${{ inputs.create_edge_release || github.event.schedule }} | |
steps: | |
- name: Checkout source code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Needed by goreleaser to browse history. | |
- name: Determine edge tag | |
# This tag is semver and works with semver.Compare | |
run: echo "EDGE_TAG=0.0.0-edge.$(date +%Y-%m-%d)" >> $GITHUB_ENV | |
- name: Set edge tag | |
id: tag_version | |
uses: mathieudutour/[email protected] | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
custom_tag: ${{ env.EDGE_TAG }} | |
tag_prefix: "" | |
- name: Set up go | |
uses: actions/setup-go@v5 | |
with: | |
go-version-file: ./go.mod | |
- name: Build snapshot with goreleaser | |
uses: goreleaser/goreleaser-action@v3 | |
with: | |
distribution: goreleaser | |
version: latest | |
args: release --clean --skip-publish --skip-announce --snapshot | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
TELEMETRY_KEY: ${{ secrets.TELEMETRY_KEY }} | |
SENTRY_DSN: ${{ secrets.SENTRY_DSN }} | |
- name: Create Sentry release | |
uses: getsentry/action-release@v1 | |
env: | |
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} | |
SENTRY_ORG: ${{ vars.SENTRY_ORG }} | |
SENTRY_PROJECT: ${{ vars.SENTRY_PROJECT }} | |
with: | |
environment: development | |
version: ${{ env.EDGE_TAG }} | |
version_prefix: "devbox@" | |
- name: Publish snapshot release to GitHub | |
uses: softprops/action-gh-release@v1 | |
with: | |
prerelease: true | |
body: "${{ env.EDGE_TAG }} edge release" | |
fail_on_unmatched_files: true | |
tag_name: ${{ env.EDGE_TAG }} | |
files: | | |
dist/checksums.txt | |
dist/*.tar.gz | |
- name: Configure AWS Credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
role-to-assume: ${{ secrets.AWS_ROLE }} | |
aws-region: us-west-2 | |
- name: Update edge version in s3 | |
run: | | |
tmp_file=$(mktemp) | |
echo "${{ env.EDGE_TAG }}" > $tmp_file | |
aws s3 cp $tmp_file s3://releases.jetpack.io/devbox/edge/version | |
release: | |
runs-on: ubuntu-latest | |
environment: release | |
needs: tests | |
# Only release when there's a tag for the release. | |
if: startsWith(github.ref, 'refs/tags/') | |
steps: | |
- name: Checkout source code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Needed by goreleaser to browse history. | |
- name: Set up go | |
uses: actions/setup-go@v5 | |
with: | |
go-version-file: ./go.mod | |
- name: Create Sentry release | |
uses: getsentry/action-release@v1 | |
env: | |
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} | |
SENTRY_ORG: ${{ vars.SENTRY_ORG }} | |
SENTRY_PROJECT: ${{ vars.SENTRY_PROJECT }} | |
with: | |
environment: production | |
version: ${{ github.ref }} | |
version_prefix: "devbox@" | |
- name: Release with goreleaser | |
uses: goreleaser/goreleaser-action@v3 | |
with: | |
distribution: goreleaser | |
version: latest | |
args: release --clean | |
env: | |
DISCORD_WEBHOOK_ID: ${{ secrets.DISCORD_WEBHOOK_ID }} | |
DISCORD_WEBHOOK_TOKEN: ${{ secrets.DISCORD_WEBHOOK_TOKEN }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
TELEMETRY_KEY: ${{ secrets.TELEMETRY_KEY }} | |
SENTRY_DSN: ${{ secrets.SENTRY_DSN }} | |
- name: Notify jetpack.io slack of release status | |
id: slack | |
if: always() | |
uses: slackapi/[email protected] | |
with: | |
payload: | | |
{ | |
"status": "release ${{ job.status }}" | |
} | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_CLI_RELEASE_WEBHOOK_URL }} |