Repository navigation
91 lines (87 loc) · 2.95 KB
/
Copy pathrelease.yml
File metadata and controls
91 lines (87 loc) · 2.95 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
91
name: Release container
on:
push:
branches: [master]
paths: ['pyproject.toml']
workflow_dispatch:
permissions:
contents: read
concurrency:
group: server-release-${{ github.ref }}
cancel-in-progress: false
jobs:
version:
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
outputs:
release: ${{ steps.version.outputs.release }}
version: ${{ steps.version.outputs.version }}
tag: ${{ steps.version.outputs.tag }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- run: python -m unittest discover -s tools/tests -v
- name: Check committed version
id: version
env:
BEFORE: ${{ github.event.before }}
EVENT_NAME: ${{ github.event_name }}
run: |
if [ "$EVENT_NAME" = workflow_dispatch ]; then
python tools/release_gate.py server --manual
else
python tools/release_gate.py server --base "$BEFORE"
fi
image:
needs: version
if: needs.version.outputs.release == 'true'
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/build-push-action@v6
id: image
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
tags: |
ghcr.io/papyrusreader/server:${{ needs.version.outputs.version }}
ghcr.io/papyrusreader/server:sha-${{ github.sha }}
labels: |
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
org.opencontainers.image.version=${{ needs.version.outputs.version }}
org.opencontainers.image.revision=${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Record published digest
env:
DIGEST: ${{ steps.image.outputs.digest }}
VERSION: ${{ needs.version.outputs.version }}
run: printf 'ghcr.io/papyrusreader/server:%s\nDigest %s\n' "$VERSION" "$DIGEST" > image.txt
- uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.version.outputs.tag }}
target_commitish: ${{ github.sha }}
generate_release_notes: true
files: image.txt
- name: Remove superseded initial container
if: needs.version.outputs.version == '0.0.1'
env:
VERSION: ${{ needs.version.outputs.version }}
IMAGE_DIGEST: ${{ steps.image.outputs.digest }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: python tools/remove_superseded_release.py