Skip to content

Commit f972e09

Browse files
authored
feat: New release flow (#1201)
1 parent c00b52b commit f972e09

File tree

8 files changed

+158
-874
lines changed

8 files changed

+158
-874
lines changed

.github/repo_policies/BOT_APPROVED_FILES

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ replica-releases.*
77
Cargo.Bazel.lock
88
pyproject.toml
99
requirements.*lock
10-
CHANGELOG.md
10+
VERSION

.github/workflows/dre-release.yaml

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
name: Release DRE binary
2+
on:
3+
push:
4+
tags:
5+
- "v*"
6+
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
9+
cancel-in-progress: true
10+
11+
jobs:
12+
test:
13+
runs-on:
14+
labels: dre-runner-custom
15+
container: ghcr.io/dfinity/dre/actions-runner:3dd4f38f076cad73fdcc68ad37fd29bed4fa3e4d
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: "☁️ Setup runner"
20+
uses: ./.github/workflows/manage-runner-pre
21+
22+
- name: "🚀 Testing"
23+
env:
24+
STAGING_PRIVATE_KEY_PEM: "${{ secrets.STAGING_PRIVATE_KEY_PEM }}"
25+
run: |
26+
mkdir -p ~/.config/dfx/identity/bootstrap-super-leader/
27+
echo $STAGING_PRIVATE_KEY_PEM > ~/.config/dfx/identity/bootstrap-super-leader/identity.pem
28+
bazel test //rs/cli:unit_test --spawn_strategy=local --test_env=HOME=/home/runner
29+
30+
release:
31+
needs: [ test ]
32+
runs-on:
33+
labels: dre-runner-custom
34+
container: ghcr.io/dfinity/dre/actions-runner:3dd4f38f076cad73fdcc68ad37fd29bed4fa3e4d
35+
permissions:
36+
contents: write
37+
packages: write
38+
pages: write
39+
steps:
40+
- uses: actions/checkout@v4
41+
with:
42+
fetch-tags: true
43+
fetch-depth: 0
44+
45+
- name: "☁️ Setup runner"
46+
uses: ./.github/workflows/manage-runner-pre
47+
48+
# The GitHub App token is necessary for pushing changed files back to the repository
49+
# If regular secrets.GITHUB_TOKEN is used instead, the push will not trigger any actions
50+
# https://github.com/orgs/community/discussions/25702
51+
- name: Create GitHub App Token
52+
uses: actions/create-github-app-token@v1
53+
id: app-token
54+
with:
55+
app-id: ${{ vars.PR_AUTOMATION_BOT_PUBLIC_APP_ID }}
56+
private-key: ${{ secrets.PR_AUTOMATION_BOT_PUBLIC_PRIVATE_KEY }}
57+
58+
- name: Determine tag
59+
shell: bash
60+
id: tag
61+
run: |
62+
TAG=${GITHUB_REF#refs/tags/}
63+
if [[ $TAG == refs/* ]]; then
64+
echo "Invalid value for tag $TAG"
65+
exit 1
66+
fi
67+
68+
echo "Will be using tag $TAG"
69+
echo "tag=$TAG" >> $GITHUB_OUTPUT
70+
71+
- name: Update tags in code
72+
shell: bash
73+
run: |
74+
rye run python bin/mk-release.py ${{ steps.tag.outputs.tag }}
75+
76+
- name: Build artifacts
77+
shell: bash
78+
run: |
79+
cargo install git-cliff
80+
rustup target add x86_64-apple-darwin
81+
CARGO_BAZEL_REPIN=true bazel build --config=ci //rs/cli:dre
82+
cargo drecross
83+
84+
mkdir -p release/artifacts
85+
cp --dereference bazel-out/k8-opt/bin/rs/cli/dre release/artifacts/dre-x86_64-unknown-linux
86+
cp target/x86_64-apple-darwin/release/dre release/artifacts/dre-x86_64-apple-darwin
87+
88+
git cliff --current --sort newest > release/CHANGELOG.md
89+
90+
- name: "🆕 📢 Prepare release"
91+
# v0.1.15
92+
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844
93+
id: release
94+
with:
95+
token: ${{ secrets.GITHUB_TOKEN }}
96+
name: ${{ steps.tag.outputs.tag }}
97+
tag_name: ${{ steps.tag.outputs.tag }}
98+
body_path: release/CHANGELOG.md
99+
draft: true
100+
prerelease: true
101+
files: |
102+
release/artifacts/*
103+
104+
- name: "Clean up release artifacts"
105+
shell: bash
106+
run: |
107+
rm -rf release
108+
109+
- name: "🆕 Create a new Pull Request with the changes"
110+
uses: peter-evans/create-pull-request@v7
111+
with:
112+
commit-message: "chore(release): New release of `dre` version ${{ steps.tag.outputs.tag }}"
113+
branch: bot-release-${{ steps.tag.outputs.tag }}
114+
title: "chore(release): New release of `dre` version ${{ steps.tag.outputs.tag }}"
115+
body: |
116+
This PR updates versions in the code used to generate the contents of a new release [${{ steps.tag.outputs.tag }}](${{ steps.release.outputs.url }})
117+
118+
If the release notes are correct, set it as latest release and publish it.
119+
token: ${{ steps.app-token.outputs.token }}
120+
base: main
121+

.github/workflows/main.yaml

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ on:
33
push:
44
branches:
55
- "main"
6-
tags:
7-
- "v*"
86
paths-ignore:
97
- "release-index.yaml"
108
- "replica-releases/**"
@@ -87,16 +85,6 @@ jobs:
8785
name: test-artifacts
8886
path: bazel-out/k8-opt/bin/rs/ic-observability/multiservice-discovery/multiservice-discovery
8987

90-
########################################
91-
# Prepare release
92-
########################################
93-
- name: "🚢 Prepare release"
94-
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
95-
uses: ./.github/workflows/prepare-release
96-
with:
97-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
98-
PUSH_TOKEN: ${{ steps.app-token.outputs.token }}
99-
10088
########################################
10189
# Upload container images
10290
########################################
@@ -107,7 +95,7 @@ jobs:
10795
username: ${{ github.actor }}
10896
password: ${{ secrets.GITHUB_TOKEN }}
10997
- name: "📦 Push images to GitHub Container Registry"
110-
if: ${{ startsWith(github.ref, 'refs/tags/v') || startsWith(github.head_ref, 'container') || startsWith(github.ref, 'refs/heads/container') || (github.ref == 'refs/heads/main') }}
98+
if: ${{ startsWith(github.head_ref, 'container') || startsWith(github.ref, 'refs/heads/container') || (github.ref == 'refs/heads/main') }}
11199
run: bazel query --noshow_progress 'kind("oci_push", ...)' | xargs -I_target bazel run _target -- --tag ${GITHUB_SHA}
112100

113101
########################################

.github/workflows/prepare-release/action.yaml

Lines changed: 0 additions & 67 deletions
This file was deleted.

0 commit comments

Comments
 (0)