summaryrefslogtreecommitdiffstats
path: root/.github/workflows/deployment.yml
blob: d3da34ac5c9e9d50156ce37ac82dd7bda29a59b3 (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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# How we deploy a release. Covers binary builds. Also manages packaging for choco.
#
# Based on https://github.com/BurntSushi/ripgrep/blob/master/.github/workflows/release.yml

name: deployment

on:
  workflow_dispatch:
    inputs:
      tag:
        description: "Which tag to deploy as:"
        required: true
  push:
    tags:
      - "[0-9]+.[0-9]+.[0-9]+"

env:
  CARGO_INCREMENTAL: 0
  CARGO_PROFILE_DEV_DEBUG: 0
  CARGO_HUSKY_DONT_INSTALL_HOOKS: true

jobs:
  initialize:
    name: initialize
    runs-on: ubuntu-latest
    outputs:
      version: ${{ env.VERSION }}
    steps:
      - name: Get the release version from the tag
        if: env.VERSION == ''
        run: |
          if [[ -n "${{ github.event.inputs.tag }}" ]]; then
            echo "Manual run against a tag; overriding actual tag in the environment..."
            echo "VERSION=${{ github.event.inputs.tag }}" >> $GITHUB_ENV
          else
            echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
          fi

      - name: Validate version environment variable
        run: |
          echo "Version being built against is version ${{ env.VERSION }}"!

  build-release:
    needs: [initialize]
    uses: ./.github/workflows/build_releases.yml
    with:
      caller: "deployment"
    secrets: inherit

  generate-choco:
    needs: [initialize, build-release]
    name: "Generate Chocolatey files"
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
        with:
          fetch-depth: 1

      - name: Set release version
        shell: bash
        run: |
          echo "RELEASE_VERSION=${{ needs.initialize.outputs.version }}" >> $GITHUB_ENV

      - name: Validate release version
        run: |
          echo "Release version: ${{ env.RELEASE_VERSION }}"

      - name: Get release artifacts
        uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
        with:
          name: release
          path: release

      - name: Execute choco packaging script
        run: |
          python "./scripts/windows/choco/choco_packager.py" "./release/bottom_x86_64-pc-windows-msvc.zip" ${{ env.RELEASE_VERSION }} "./scripts/windows/choco/bottom.nuspec.template" "./scripts/windows/choco/chocolateyinstall.ps1.template" "bottom.nuspec" "tools/chocolateyinstall.ps1" "tools/"
          zip -r choco.zip "bottom.nuspec" "tools"

      - name: Move release file into release directory
        shell: bash
        run: |
          mv choco.zip release/

      - name: Save release as artifact
        uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
        with:
          retention-days: 3
          name: release
          path: release

  upload-release:
    name: upload-release
    runs-on: ubuntu-latest
    needs: [initialize, generate-choco, build-release]
    steps:
      - name: Set release version
        shell: bash
        run: |
          echo "RELEASE_VERSION=${{ needs.initialize.outputs.version }}" >> $GITHUB_ENV

      - name: Validate release version
        run: |
          echo "Release version: ${{ env.RELEASE_VERSION }}"

      - name: Get release artifacts
        uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
        with:
          name: release
          path: release

      - name: Print out all release files
        run: |
          echo "Generated $(ls ./release | wc -l) files:"
          du -h -d 0 ./release/*

      - name: Upload all saved release files
        uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # 0.1.15
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          prerelease: false
          tag_name: ${{ env.RELEASE_VERSION }}
          draft: true
          fail_on_unmatched_files: true
          name: ${{ env.RELEASE_VERSION }} Release
          body: |
            <!-- Write summary here -->

            ---

            ## Bug Fixes
              
            ## Features
              
            ## Changes

            ## Other

            ## Internal Changes
          files: |
            ./release/*