Skip to content

Commit 43d3391

Browse files
committed
[Experimental] Add auto tag GHA
1 parent 0e2f66a commit 43d3391

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

.github/workflows/tag.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Auto Tag
2+
3+
on:
4+
schedule:
5+
- cron: '0 0 31 1 *'
6+
7+
env:
8+
NEXT_TAG: '41'
9+
SSH_REPO: '[email protected]:${{ github.repository }}.git'
10+
11+
jobs:
12+
tag:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout
17+
uses: actions/[email protected]
18+
- name: Checkout
19+
uses: actions/[email protected]
20+
with:
21+
repository: 'rust-lang/rust'
22+
ref: '1.${{ env.NEXT_TAG }}.0'
23+
path: 'rust'
24+
- name: Get Clippy commit
25+
working-directory: rust
26+
run: |
27+
git submodule init src/tools/clippy
28+
CLIPPY_SHA=$(git submodule status -- src/tools/clippy | grep -o '\s[0-9a-f]*\s' | tr -d '[:space:]')
29+
echo "::set-env name=CLIPPY_SHA::$CLIPPY_SHA"
30+
- name: Set SSH deploy key
31+
run: |
32+
eval "$(ssh-agens -s)"
33+
ssh-add - <<< ${{ secrets.DEPLOY_KEY }}
34+
- name: Tag Clippy commit
35+
run: |
36+
git checkout $CLIPPY_SHA
37+
git tag 'rust-1.$NEXT_TAG.0'
38+
git push $SSH_REPO --tags
39+
- name: Update GHA Auto Tag
40+
run: |
41+
git checkout master
42+
43+
TIME=$(date -u +%s)
44+
let NEXT_RELEASE="$TIME+6*7*24*60*60"
45+
DATE=$(date -u --date="@$NEXT_RELEASE" +%-d\ %-m)
46+
CRON="0 0 $DATE *"
47+
sed -i "s/cron: '[0-9* ]*'/cron: '$CRON'/" .github/workflows/tag.yml
48+
49+
let NEW_TAG="$NEXT_TAG+1"
50+
sed -i "s/NEXT_TAG: '[0-9]*'/NEXT_TAG: '$NEW_TAG'/" .github/workflows/tag.yml
51+
52+
git add .github/workflows/tag.yml
53+
git commit -m "Update GHA tag workflow"
54+
git push $SSH_REPO

0 commit comments

Comments
 (0)