-
Notifications
You must be signed in to change notification settings - Fork 2
90 lines (89 loc) · 3.26 KB
/
tag-and-release.yml
File metadata and controls
90 lines (89 loc) · 3.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
---
name: Tag & Release
'on':
workflow_call:
inputs:
upstream:
description: Upstream repository URL
type: string
required: false
jobs:
turnstyle:
runs-on: ubuntu-latest
name: Serialise runs of this workflow
permissions:
actions: read
steps:
# Concurrent runs of this workflow can fail due to conflicting changes in tags.
# The GitHub workflow concurrency option works to some degree, but only a
# single job can be queued concurrently, and older queued jobs get
# cancelled. This makes sense for a deployment, but not for a tagging
# workflow.
- name: Serialise runs of this workflow
uses: softprops/turnstyle@ca99add00ff0c9cbc697d22631d2992f377e5bd5
with:
continue-after-seconds: 180
poll-interval-seconds: 30
same-branch-only: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
tag:
runs-on: ubuntu-latest
env:
naming-things-is-hard-repository: stackhpc/naming-things-is-hard
name: Automatic tagging for ${{ github.ref_name }} 🏷
needs: [turnstyle]
steps:
- name: Github checkout 🛎 [${{ github.repository }}]
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Configure repository 🛠
run: |
upstream="${{ inputs.upstream }}"
if [[ -z "$upstream" ]]; then
upstream="https://github.com/openstack/$(basename $(pwd)).git"
fi
git remote rename origin stackhpc &&
git remote add origin "$upstream"
- name: Push upstream tags to downstream fork 🏷
run: |
git fetch origin &&
git push stackhpc --follow-tags
- name: Github checkout 🛎 [${{ env.naming-things-is-hard-repository }}]
uses: actions/checkout@v4
with:
repository: ${{ env.naming-things-is-hard-repository }}
path: naming-things-is-hard
- name: Run naming-things-is-hard/os-downstream-tag
run: naming-things-is-hard/os-downstream-tag.py --release $(basename $(git rev-parse --abbrev-ref HEAD))
release:
needs: [tag]
runs-on: ubuntu-latest
name: Release newly generated tag 🏷
steps:
- name: Github checkout 🛎 [${{ github.repository }}]
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get tag 🏷
id: commit-tag
run: echo "value=$(git describe --tags --abbrev=0)" >> $GITHUB_OUTPUT
- name: Generate release notes 📝
run: git log --pretty="%h %s" $(git describe --tags --abbrev=0)...$(git describe --tags --abbrev=0 $(git describe --tags --abbrev=0)^) > changelog.txt
- name: Publish release 🚀
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TAG_NAME="${{ steps.commit-tag.outputs.value }}"
# Fail if release already exists
if gh release view "$TAG_NAME" > /dev/null 2>&1; then
echo "Release for $TAG_NAME already exists. Releases are immutable."
exit 1
else
echo "Creating release for $TAG_NAME"
gh release create "$TAG_NAME" \
--title "$TAG_NAME" \
--notes-file changelog.txt \
LICENSE
fi