fork/fish-shell

git clone https://git.julia.blue/fork/fish-shell

Johannes Altmanningerbuild_tools/update-dependencies.sha3b009dd4

master
8.2 KiB196 linesraw
1name: Create a new release
2
3on:
4  workflow_dispatch:
5    inputs:
6      version:
7        description: 'Version to release (tag name)'
8        required: true
9        type: string
10
11permissions:
12  contents: write
13
14jobs:
15  is-release-tag:
16    name: Pre-release checks
17    runs-on: ubuntu-latest
18    steps:
19      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2, build_tools/update-dependencies.sh
20        with:
21          # Workaround for https://github.com/actions/checkout/issues/882
22          ref: ${{ inputs.version }}
23      - name: Check if the pushed tag looks like a release
24        run: |
25          set -x
26          commit_subject=$(git log -1 --format=%s)
27          tag=$(git describe)
28          [ "$commit_subject" = "Release $tag" ]
29
30
31  source-tarball:
32    needs: [is-release-tag]
33    name: Create the source tarball
34    runs-on: ubuntu-latest
35    outputs:
36      version: ${{ steps.version.outputs.version }}
37      tarball-name: ${{ steps.version.outputs.tarball-name }}
38    steps:
39      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2, build_tools/update-dependencies.sh
40        with:
41          # Workaround for https://github.com/actions/checkout/issues/882
42          ref: ${{ inputs.version }}
43      - name: Update package database
44        run: sudo apt-get update
45      - name: Install dependencies
46        run: sudo apt install cmake gettext ninja-build python3-pip
47      - uses: ./.github/actions/install-sphinx
48      - name: Create tarball
49        run: |
50          set -x
51          mkdir /tmp/fish-built
52          FISH_ARTEFACT_PATH=/tmp/fish-built ./build_tools/make_tarball.sh
53          relnotes=/tmp/fish-built/release-notes.md
54          # Need history since the last release (i.e. tag) for stats.
55          git fetch --tags
56          git fetch --unshallow
57          gpg_public_key_url=https://github.com/${{ github.actor }}.gpg
58          curl -sS "$gpg_public_key_url" | grep 'PGP PUBLIC KEY BLOCK' -A5
59          FISH_GPG_PUBLIC_KEY_URL=$gpg_public_key_url \
60            sh -x ./build_tools/release-notes.sh >"$relnotes"
61          # Delete title
62          sed -n 1p "$relnotes" | grep -q "^## fish .*"
63          sed -n 2p "$relnotes" | grep -q '^$'
64          sed -i 1,2d "$relnotes"
65      - name: Upload tarball artifact
66        uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1, build_tools/update-dependencies.sh
67        with:
68          name: source-tarball
69          path: |
70            /tmp/fish-built/fish-${{ inputs.version }}.tar.xz
71            /tmp/fish-built/release-notes.md
72          if-no-files-found: error
73
74  packages-for-linux:
75    needs: [is-release-tag]
76    name: Build single-file fish for Linux
77    runs-on: ubuntu-latest
78    steps:
79      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2, build_tools/update-dependencies.sh
80        with:
81          # Workaround for https://github.com/actions/checkout/issues/882
82          ref: ${{ inputs.version }}
83      - name: Install Rust Stable
84        uses: ./.github/actions/rust-toolchain@stable
85        with:
86          targets: x86_64-unknown-linux-musl,aarch64-unknown-linux-musl
87      - name: Update package database
88        run: sudo apt-get update
89      - name: Install dependencies
90        run: sudo apt install crossbuild-essential-arm64 gettext musl-tools
91      - uses: ./.github/actions/install-sphinx
92      - name: Build statically-linked executables
93        run: |
94          set -x
95          cargo build --release --target x86_64-unknown-linux-musl --bin fish
96          CFLAGS="-D_FORTIFY_SOURCE=2" \
97            CC=aarch64-linux-gnu-gcc \
98            RUSTFLAGS="-C linker=aarch64-linux-gnu-gcc -C link-arg=-lgcc -C link-arg=-D_FORTIFY_SOURCE=0" \
99            cargo build --release --target aarch64-unknown-linux-musl --bin fish
100      - name: Compress
101        run: |
102          set -x
103          for arch in x86_64 aarch64; do
104            tar -cazf fish-$(git describe)-linux-$arch.tar.xz \
105              -C target/$arch-unknown-linux-musl/release fish
106          done
107      - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1, build_tools/update-dependencies.sh
108        with:
109          name: Static builds for Linux
110          path: fish-${{ inputs.version }}-linux-*.tar.xz
111          if-no-files-found: error
112
113  create-draft-release:
114    needs:
115      - is-release-tag
116      - source-tarball
117      - packages-for-linux
118    name: Create release draft
119    runs-on: ubuntu-latest
120    steps:
121      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2, build_tools/update-dependencies.sh
122        with:
123          # Workaround for https://github.com/actions/checkout/issues/882
124          ref: ${{ inputs.version }}
125      - name: Download all artifacts
126        uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1, build_tools/update-dependencies.sh
127        with:
128          merge-multiple: true
129          path: /tmp/artifacts
130      - name: List artifacts
131        run: find /tmp/artifacts -type f
132      - name: Create draft release
133        uses: softprops/action-gh-release@b4309332981a82ec1c5618f44dd2e27cc8bfbfda # v3.0.0, build_tools/update-dependencies.sh
134        with:
135          tag_name: ${{ inputs.version }}
136          name: fish ${{ inputs.version }}
137          body_path: /tmp/artifacts/release-notes.md
138          draft: true
139          files: |
140            /tmp/artifacts/fish-${{ inputs.version }}.tar.xz
141            /tmp/artifacts/fish-${{ inputs.version }}-linux-*.tar.xz
142
143  packages-for-macos:
144    needs: [is-release-tag, create-draft-release]
145    name: Build packages for macOS
146    runs-on: macos-latest
147    environment: macos-codesign
148    steps:
149      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2, build_tools/update-dependencies.sh
150        with:
151          # Workaround for https://github.com/actions/checkout/issues/882
152          ref: ${{ inputs.version }}
153      - name: Install Rust
154        uses: ./.github/actions/rust-toolchain@stable
155        with:
156          targets: aarch64-apple-darwin,x86_64-apple-darwin
157      - name: Install dependencies
158        run: brew install gettext
159      - uses: ./.github/actions/install-sphinx
160      - name: Build and codesign
161        run: |
162          die() { echo >&2 "$*"; exit 1; }
163          [ -n "$MAC_CODESIGN_APP_P12_BASE64" ] || die "Missing MAC_CODESIGN_APP_P12_BASE64"
164          [ -n "$MAC_CODESIGN_INSTALLER_P12_BASE64" ] || die "Missing MAC_CODESIGN_INSTALLER_P12_BASE64"
165          [ -n "$MAC_CODESIGN_PASSWORD" ] || die "Missing MAC_CODESIGN_PASSWORD"
166          [ -n "$MACOS_NOTARIZE_JSON" ] || die "Missing MACOS_NOTARIZE_JSON"
167          set -x
168          export FISH_ARTEFACT_PATH=/tmp/fish-built
169          # macOS runners keep having issues loading Cargo.toml dependencies from git (GitHub) instead
170          # of crates.io, so give this a try. It's also sometimes significantly faster on all platforms.
171          export CARGO_NET_GIT_FETCH_WITH_CLI=true
172          cargo install apple-codesign
173          mkdir -p "$FISH_ARTEFACT_PATH"
174          echo "$MAC_CODESIGN_APP_P12_BASE64" | base64 --decode >/tmp/app.p12
175          echo "$MAC_CODESIGN_INSTALLER_P12_BASE64" | base64 --decode >/tmp/installer.p12
176          echo "$MACOS_NOTARIZE_JSON" >/tmp/notarize.json
177          ./build_tools/make_macos_pkg.sh -s -f /tmp/app.p12 \
178            -i /tmp/installer.p12 -p "$MAC_CODESIGN_PASSWORD" \
179            -n -j /tmp/notarize.json -- -c "-DWITH_DOCS=ON"
180          version=$(git describe)
181          [ -f "${FISH_ARTEFACT_PATH}/fish-$version.app.zip" ]
182          [ -f "${FISH_ARTEFACT_PATH}/fish-$version.pkg" ]
183          rm /tmp/installer.p12 /tmp/app.p12 /tmp/notarize.json
184        env:
185          MAC_CODESIGN_APP_P12_BASE64: ${{ secrets.MAC_CODESIGN_APP_P12_BASE64 }}
186          MAC_CODESIGN_INSTALLER_P12_BASE64: ${{ secrets.MAC_CODESIGN_INSTALLER_P12_BASE64 }}
187          MAC_CODESIGN_PASSWORD: ${{ secrets.MAC_CODESIGN_PASSWORD }}
188          MACOS_NOTARIZE_JSON: ${{ secrets.MACOS_NOTARIZE_JSON }}
189      - name: Add macOS packages to the release
190        env:
191          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
192        run: |
193          version=$(git describe)
194          gh release upload $version \
195            /tmp/fish-built/fish-$version.app.zip \
196            /tmp/fish-built/fish-$version.pkg