Fork of daniellemaywood.uk/gleam — Wasm codegen work
1name: release-nightly
2
3on:
4 workflow_dispatch:
5 schedule:
6 - cron: "45 0 * * *"
7
8env:
9 CARGO_TERM_COLOR: always
10 RUSTFLAGS: "-D warnings"
11
12permissions:
13 contents: write
14 packages: write
15 id-token: write
16 attestations: write
17
18jobs:
19 # Check if the actions already ran in the last 24 hours
20 # * If yes: Don't run again
21 # * If no: Clean out existing release assets
22 prepare-nightly:
23 runs-on: ubuntu-latest
24 name: Prepare Nightly Release
25 outputs:
26 should-run: ${{ steps.should-run.outputs.should-run }}
27 # TODO: Re-add
28 # if: ${{ github.repository == 'gleam-lang/gleam' }}
29 steps:
30 - uses: actions/checkout@v4
31 - name: print latest_commit
32 run: echo ${{ github.sha }}
33
34 - id: should-run
35 continue-on-error: true
36 name: check latest commit is less than a day
37 if: ${{ github.event_name == 'schedule' }}
38 run: test -z $(git rev-list --after="24 hours" ${{ github.sha }}) && echo "should-run=false" >> $GITHUB_OUTPUT
39
40 - name: Delete old release assets
41 uses: mknejp/delete-release-assets@v1
42 if: ${{ steps.should-run != 'false' }}
43 with:
44 token: ${{ github.token }}
45 tag: nightly
46 fail-if-no-assets: false
47 fail-if-no-release: false
48 assets: |
49 *.zip
50 *.tar.gz
51 *.sha256
52 *.sha512
53 *.sigstore
54 *.sbom.*.json
55
56 build-release:
57 name: build-release
58 runs-on: ${{ matrix.os }}
59 outputs:
60 release-id: ${{ steps.release.outputs.id }}
61 strategy:
62 matrix:
63 target:
64 - x86_64-unknown-linux-musl
65 - aarch64-unknown-linux-musl
66 - x86_64-apple-darwin
67 - aarch64-apple-darwin
68 - x86_64-pc-windows-msvc
69 toolchain: [ stable ]
70 include:
71 - os: ubuntu-latest
72 target: x86_64-unknown-linux-musl
73 expected-binary-architecture: x86-64
74 cargo-tool: cross
75 - os: ubuntu-latest
76 target: aarch64-unknown-linux-musl
77 expected-binary-architecture: aarch64
78 cargo-tool: cross
79 # macos>=14 runs exclusively on aarch64 and will thus fail to execute properly for x64
80 - os: macos-13
81 target: x86_64-apple-darwin
82 expected-binary-architecture: x86_64
83 cargo-tool: cargo
84 - os: macos-latest
85 target: aarch64-apple-darwin
86 expected-binary-architecture: arm64
87 cargo-tool: cargo
88 - os: windows-latest
89 target: x86_64-pc-windows-msvc
90 expected-binary-architecture: x86-64
91 cargo-tool: cargo
92 - os: ubuntu-latest
93 target: wasm32-unknown-unknown
94 cargo-tool: wasm-pack
95 steps:
96 - name: Checkout repository
97 uses: actions/checkout@v4
98
99 - name: Update versions
100 shell: bash
101 run: ./bin/add-nightly-suffix-to-versions.sh
102
103 - name: "Build Archive"
104 id: build
105 uses: "./.github/actions/build-release"
106 with:
107 version: nightly
108 toolchain: ${{ matrix.toolchain }}
109 target: ${{ matrix.target }}
110 cargo-tool: ${{ matrix.cargo-tool }}
111 expected-binary-architecture: ${{ matrix.expected-binary-architecture }}
112
113 - name: Upload release archive
114 id: release
115 # https://github.com/softprops/action-gh-release/issues/445
116 # uses: softprops/action-gh-release@v2
117 uses: softprops/action-gh-release@0bd7e8b279c9b5b36661d552472fbbfe671fe26e
118 with:
119 draft: false
120 prerelease: true
121 fail_on_unmatched_files: true
122 files: "${{ steps.build.outputs.files }}"
123 tag_name: nightly
124 name: "Nightly"
125 body: |
126 A build that runs every night following changes to the main branch. Contains all the latest features and changes, but there is a higher chance of instability, bugs, and unfinished features.
127
128 The assets are updated but the tag is not, so if you view the commit or download the source from below you will not get the correct code.
129
130 build-container-images:
131 name: build-container-images
132 needs: [ prepare-nightly, build-release ]
133 runs-on: ubuntu-latest
134 if: ${{ needs.prepare-nightly.outputs.should-run != 'false' }}
135 strategy:
136 matrix:
137 base-image:
138 - scratch
139 - erlang
140 - erlang-slim
141 - erlang-alpine
142 - elixir
143 - elixir-slim
144 - elixir-alpine
145 - node
146 - node-slim
147 - node-alpine
148
149 steps:
150 - name: Checkout repository
151 uses: actions/checkout@v4
152 with:
153 sparse-checkout: |
154 .github/actions
155 containers
156
157 - name: "Build & Push Container"
158 uses: "./.github/actions/build-container"
159 with:
160 version: nightly
161 release-id: ${{ needs.build-release.outputs.release-id }}