Skip to content
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
15 changes: 12 additions & 3 deletions .github/workflows/release-zed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ jobs:
tag:
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
environment: release
permissions:
contents: write
contents: read
pull-requests: read
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
Expand Down Expand Up @@ -61,9 +62,17 @@ jobs:
and .title == "chore(zed): release \($tag | ltrimstr("zed-"))")' > /dev/null ||
{ echo "::error::$GITHUB_SHA is not a merged chore/release-${TAG#zed-v} PR titled \"chore(zed): release ${TAG#zed-}\""; exit 1; }

# Only deploy keys may create release tags (the tag ruleset), so the push goes over SSH with the
# `release` environment's key. The agent holding it ends with this step, and the key never hits disk.
- name: Create tag
if: steps.tag.outputs.due == 'true'
run: gh api "repos/$GITHUB_REPOSITORY/git/refs" -f ref="refs/tags/$TAG" -f sha="$GITHUB_SHA"
run: |
eval "$(ssh-agent -s)" > /dev/null
trap 'ssh-agent -k > /dev/null' EXIT
ssh-add -q - <<< "$RELEASE_TAG_KEY"
curl -fsS https://api.github.com/meta | jq -r '.ssh_keys[] | "github.com \(.)"' > "$RUNNER_TEMP/known_hosts"
git -c core.sshCommand="ssh -o UserKnownHostsFile=$RUNNER_TEMP/known_hosts" \
push "git@github.com:$GITHUB_REPOSITORY.git" "$GITHUB_SHA:refs/tags/$TAG"
env:
GH_TOKEN: ${{ github.token }}
RELEASE_TAG_KEY: ${{ secrets.RELEASE_TAG_KEY }}
TAG: ${{ steps.tag.outputs.tag }}
19 changes: 15 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,24 @@ jobs:
tag:
needs: [verify, build]
runs-on: ubuntu-latest
permissions:
contents: write
environment: release
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false

# Only deploy keys may create release tags (the tag ruleset), so the push goes over SSH with the
# `release` environment's key. The agent holding it ends with this step, and the key never hits disk.
- name: Create tag
run: gh api "repos/$GITHUB_REPOSITORY/git/refs" -f ref="refs/tags/$TAG" -f sha="$GITHUB_SHA"
run: |
eval "$(ssh-agent -s)" > /dev/null
trap 'ssh-agent -k > /dev/null' EXIT
ssh-add -q - <<< "$RELEASE_TAG_KEY"
curl -fsS https://api.github.com/meta | jq -r '.ssh_keys[] | "github.com \(.)"' > "$RUNNER_TEMP/known_hosts"
git -c core.sshCommand="ssh -o UserKnownHostsFile=$RUNNER_TEMP/known_hosts" \
push "git@github.com:$GITHUB_REPOSITORY.git" "$GITHUB_SHA:refs/tags/$TAG"
env:
GH_TOKEN: ${{ github.token }}
RELEASE_TAG_KEY: ${{ secrets.RELEASE_TAG_KEY }}
TAG: ${{ needs.verify.outputs.tag }}

publish:
Expand Down
Loading