Thanks to visit codestin.com
Credit goes to github.com

Skip to content

ci: Fix release workflow input booleans, remove snapshot #5688

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jan 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 24 additions & 15 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# GitHub release workflow.
name: Release
run-name: Release ${{ github.ref_name }}${{ inputs.dry_run && ' (DRYRUN)' || '' }}
on:
workflow_dispatch:
inputs:
Expand All @@ -22,10 +23,6 @@ on:
type: boolean
required: true
default: false
snapshot:
description: Force a dev version to be generated, implies dry_run.
type: boolean
default: false
ignore_missing_commit_metadata:
description: WARNING! This option disables the requirement that all commits have a PR. Not needed for dry_run.
type: boolean
Expand All @@ -39,11 +36,17 @@ permissions:
# Necessary for GCP authentication (https://github.com/google-github-actions/setup-gcloud#usage)
id-token: write

env:
CODER_RELEASE: ${{ !github.event.inputs.snapshot }}

concurrency: ${{ github.workflow }}-${{ github.ref }}

env:
# Use `inputs` (vs `github.event.inputs`) to ensure that booleans are actual
# booleans, not strings.
# https://github.blog/changelog/2022-06-10-github-actions-inputs-unified-across-manual-and-reusable-workflows/
CODER_RELEASE: ${{ !inputs.dry_run }}
CODER_RELEASE_INCREMENT: ${{ inputs.increment }}
CODER_RELEASE_DRAFT: ${{ inputs.draft }}
CODER_DRY_RUN: ${{ inputs.dry_run }}

jobs:
release:
name: Create and publish
Expand All @@ -52,6 +55,12 @@ jobs:
# Necessary for Docker manifest
DOCKER_CLI_EXPERIMENTAL: "enabled"
steps:
- name: Check release on main (or dry-run)
if: ${{ github.ref_name != 'main' && !inputs.dry_run }}
run: |
echo "Release not allowed on ${{ github.ref_name }}, use dry-run."
exit 1

- uses: actions/checkout@v3
with:
fetch-depth: 0
Expand All @@ -76,7 +85,7 @@ jobs:
ref=HEAD
old_version="$(git describe --abbrev=0 "$ref^1")"

if [[ "${{ github.event.inputs.ignore_missing_commit_metadata }}" == *t* ]]; then
if [[ "${{ inputs.ignore_missing_commit_metadata }}" == *t* ]]; then
export CODER_IGNORE_MISSING_COMMIT_METADATA=1
fi

Expand All @@ -87,7 +96,7 @@ jobs:
fi

version_args=()
if [[ "${{ github.event.inputs.dry_run || github.event.inputs.snapshot }}" == *t* ]]; then
if [[ $CODER_DRY_RUN == *t* ]]; then
# Allow dry-run of branches to pass.
export CODER_IGNORE_MISSING_COMMIT_METADATA=1
version_args+=(--dry-run)
Expand All @@ -104,7 +113,7 @@ jobs:
./scripts/release/tag_version.sh \
"${version_args[@]}" \
--ref "$ref" \
--${{ github.event.inputs.increment }}
--"$CODER_RELEASE_INCREMENT"
)"

# Generate notes.
Expand Down Expand Up @@ -232,10 +241,10 @@ jobs:
set -euo pipefail

publish_args=()
if [[ "${{ github.event.inputs.draft }}" == *t* ]]; then
if [[ $CODER_RELEASE_DRAFT == *t* ]]; then
publish_args+=(--draft)
fi
if [[ "${{ github.event.inputs.dry_run || github.event.inputs.snapshot }}" == *t* ]]; then
if [[ $CODER_DRY_RUN == *t* ]]; then
publish_args+=(--dry-run)
fi
declare -p publish_args
Expand Down Expand Up @@ -263,7 +272,7 @@ jobs:
uses: "google-github-actions/setup-gcloud@v1"

- name: Publish Helm Chart
if: ${{ !github.event.inputs.dry_run && !github.event.inputs.snapshot }}
if: ${{ !inputs.dry_run }}
run: |
set -euo pipefail
version="$(./scripts/version.sh)"
Expand All @@ -274,8 +283,8 @@ jobs:
gsutil -h "Cache-Control:no-cache,max-age=0" cp build/helm/coder_helm_${version}.tgz gs://helm.coder.com/v2
gsutil -h "Cache-Control:no-cache,max-age=0" cp build/helm/index.yaml gs://helm.coder.com/v2

- name: Upload artifacts to actions (if dry-run or snapshot)
if: ${{ github.event.inputs.dry_run || github.event.inputs.snapshot }}
- name: Upload artifacts to actions (if dry-run)
if: ${{ inputs.dry_run }}
uses: actions/upload-artifact@v2
with:
name: release-artifacts
Expand Down
11 changes: 9 additions & 2 deletions scripts/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,18 @@ maybedryrun() {
log "DRYRUN: $*"
else
shift
log $ "$@"
"$@"
logrun "$@"
fi
}

# logrun prints the given program and flags, and then executes it.
#
# Usage: logrun gh release create ...
logrun() {
log $ "$*"
"$@"
}

# log prints a message to stderr.
log() {
echo "$*" 1>&2
Expand Down
2 changes: 1 addition & 1 deletion scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ else
fi

log
gh workflow run release.yaml \
logrun gh workflow run release.yaml \
--ref "$branch" \
-F increment="$increment" \
"${args[@]}"
Expand Down