-
Notifications
You must be signed in to change notification settings - Fork 607
71 lines (63 loc) · 2.15 KB
/
Copy pathrelease_actions.yml
File metadata and controls
71 lines (63 loc) · 2.15 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
name: Automated Release
on:
schedule:
- cron: "0 23 * * *"
permissions: {}
jobs:
release:
name: New release
if: github.repository == 'mozilla/pontoon'
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: read
steps:
- name: Clone repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
fetch-depth: 0
- name: Fetch deployed revision
id: revision
run: |
SHA=$(curl -fsS --max-time 10 \
https://pontoon.mozilla.org/static/revision.txt | tr -d '[:space:]')
if ! printf '%s' "$SHA" | grep -qE '^[0-9a-f]{40}$'; then
echo "::error::Expected a 40-character commit hash, got: ${SHA:-<empty>}"
exit 1
fi
echo "Deployed revision: $SHA"
echo "sha=$SHA" >> "$GITHUB_OUTPUT"
- name: Check for an existing release tag
id: check
env:
SHA: ${{ steps.revision.outputs.sha }}
run: |
if ! git cat-file -e "${SHA}^{commit}" 2>/dev/null; then
echo "::error::Commit $SHA is not in this repository."
exit 1
fi
TAG_EXISTS=$(git tag --points-at "$SHA" | grep '^v202' || true)
if [ -n "$TAG_EXISTS" ]; then
echo "Already released as ${TAG_EXISTS}."
echo "release=false" >> "$GITHUB_OUTPUT"
exit 0
fi
VERSION="$(date -u +v%Y.%m.%d)"
if [ -n "$(git tag -l "$VERSION")" ]; then
echo "::error::Tag $VERSION already exists."
exit 1
fi
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "release=true" >> "$GITHUB_OUTPUT"
- name: Create GitHub Release
if: steps.check.outputs.release == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ steps.check.outputs.version }}
SHA: ${{ steps.revision.outputs.sha }}
run: |
gh release create "$VERSION" \
--target "$SHA" \
--title "Release $VERSION" \
--generate-notes