summaryrefslogtreecommitdiff
path: root/.github/workflows/release-tip.yml
blob: 6283e7c780ea98bb80403eaadb53adc401180129 (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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
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 Linux Build Artifact
        uses: actions/download-artifact@v4
        with:
          name: chat-server-linux
          path: artifacts/linux/
          github-token: ${{ secrets.GITHUB_TOKEN }}
          run-id: ${{ github.event.workflow_run.id }}

      # - name: Download macOS Build Artifact
      #   uses: actions/download-artifact@v4
      #   with:
      #     name: chat-server-macos
      #     path: artifacts/macos/
      #     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/
          sha256sum chat-server-source.tar.gz > chat-server-source.tar.gz.sha256
          rm -rf chat-server-source

      - name: Prepare Linux Binary Archive
        run: |
          cd artifacts/linux
          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 ../..
          sha256sum chat-server-linux-x86_64.tar.gz > chat-server-linux-x86_64.tar.gz.sha256

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

      - 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-source.tar.gz.sha256
            chat-server-linux-x86_64.tar.gz
            chat-server-linux-x86_64.tar.gz.sha256
          token: ${{ secrets.GITHUB_TOKEN }}