summaryrefslogtreecommitdiff
path: root/.github/workflows/release-tip.yml
blob: 3c291fc9ef7f0656d4a0dbb2659e804c4c5387e2 (plain)
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
name: Release Tip

permissions:
  contents: write
  actions: read

on:
  workflow_run:
    workflows: [continuous integration]
    types: [completed]
    branches: [main]

  workflow_dispatch: {}

concurrency:
  group: ${{ github.workflow }}
  cancel-in-progress: false

jobs:
  tag:
    if: ${{ github.event.workflow_run.conclusion == 'success' }}
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - name: Create Tip Tag
        run: |
          git config user.name "github-actions[bot]"
          git config user.email "github-actions[bot]@users.noreply.github.com"
          git tag -fa tip -m "Latest Continuous Release" ${GITHUB_SHA}
          git push --force origin tip

  release:
    needs: [tag]
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - name: Download Build Artifacts
        uses: actions/download-artifact@v4
        with:
          name: chat-server
          path: artifacts/
          github-token: ${{ secrets.GITHUB_TOKEN }}
          run-id: ${{ github.event.workflow_run.id }}

      - name: Create Source Archive
        run: |
          mkdir chat-server-source
          cp -r src/ Makefile .clang-format README.md chat-server-source/ || true
          tar -czv --owner=0 --group=0 --no-same-owner --no-same-permissions -f chat-server-source.tar.gz chat-server-source/
          rm -rf chat-server-source

      - name: Prepare Binary Archive
        run: |
          cd artifacts
          chmod +x chat-server
          tar -czv --owner=0 --group=0 --no-same-owner --no-same-permissions -f ../chat-server-linux-x86_64.tar.gz *
          cd ..

      - name: Release
        uses: softprops/action-gh-release@v2
        with:
          name: 'Chat Server Tip (Latest)'
          prerelease: true
          tag_name: tip
          target_commitish: ${{ github.sha }}
          files: |
            chat-server-source.tar.gz
            chat-server-linux-x86_64.tar.gz
          token: ${{ secrets.GITHUB_TOKEN }}