Skip to content

Commit 75e38f3

Browse files
OrKoNDevtools-frontend LUCI CQ
authored andcommitted
Add a GitHub action to create version tags
The intended process is that we create tags regularly on the GitHub mirror. Then we will have a separate action that runs on tag to publish to NPM. Bug: 442357424 Change-Id: Id71435785a5e601ebd405e64e0bd4577e38cf042 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6910793 Reviewed-by: Mathias Bynens <mathias@chromium.org> Commit-Queue: Alex Rudenko <alexrudenko@chromium.org>
1 parent c82fc7d commit 75e38f3

2 files changed

Lines changed: 59 additions & 0 deletions

File tree

.github/workflows/tag.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Tag commits
2+
3+
permissions:
4+
contents: write
5+
6+
on:
7+
schedule:
8+
# Run everyday at: https://crontab.guru/#0_6_*_*_*.
9+
- cron: '0 6 * * *'
10+
workflow_dispatch:
11+
12+
jobs:
13+
tag-commits:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v5
17+
- name: Get devtools version
18+
id: devtools_version
19+
shell: bash
20+
run: devtools_version.sh
21+
- name: Create tag
22+
uses: actions/github-script@v7
23+
# This can fail if the tag exists but this is expected.
24+
continue-on-error: true
25+
env:
26+
TAG: ${{ steps.devtools_version.outputs.tag }}
27+
with:
28+
script: |
29+
await github.rest.git.createRef({
30+
owner: context.repo.owner,
31+
repo: context.repo.repo,
32+
ref: 'refs/tags/' + process.env.TAG,
33+
sha: context.sha
34+
});

scripts/devtools_version.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
3+
# This script outputs the current DevTools version (e.g., `v1.0.1509326`) for
4+
# GitHub Actions to apply as a git tag (see tag.yml).
5+
6+
# Adapted from
7+
# https://github.com/paulirish/npm-publish-devtools-frontend/blob/bc782b47c46c5fa4487ab2c46429a908a3501af2/publish-devtools-package-to-npm.sh
8+
# which evolved over 10 years.
9+
10+
# this is the chrome-for-testing version string, eg 131.0.6752.0
11+
chrome_version="$(cat DEPS | grep "'chrome'" | head -n1 | sed "s/[^0-9.]//g")"
12+
13+
# Find most recent roll of chromium INTO devtools-frontend standalone.
14+
# NOTE: this isn't exactly the same as when frontend was rolled into chromium. But.. it shouldn't make a huge difference for these purposes.. :)
15+
chromium_commit_position=$(curl "https://chromiumdash.appspot.com/fetch_releases?platform=Mac" --silent | jq --arg chrome_version "$chrome_version" '.[] | select(.version == $chrome_version).chromium_main_branch_position')
16+
17+
# verify we have a real number
18+
re='^[0-9]+$'
19+
if ! [[ $chromium_commit_position =~ $re ]] ; then
20+
echo "error: Not a number" >&2; exit 1
21+
fi
22+
23+
tag="v1.0.$chromium_commit_position"
24+
echo $tag
25+
echo "tag=$tag" >> "$GITHUB_OUTPUT"

0 commit comments

Comments
 (0)