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
12jobs:
13 # Check if the actions already ran in the last 24 hours
14 # * If yes: Don't run again
15 # * If no: Clean out existing release assets
16 prepare-nightly:
17 runs-on: ubuntu-latest
18 permissions:
19 contents: write
20 name: Prepare Nightly Release
21 outputs:
22 should-run: ${{ steps.should-run.outputs.should-run }}
23 # TODO: Re-add
24 # if: ${{ github.repository == 'gleam-lang/gleam' }}
25 steps:
26 - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
27 with:
28 persist-credentials: false
29 - name: print latest_commit
30 run: echo ${{ github.sha }}
31
32 - id: should-run
33 continue-on-error: true
34 name: check latest commit is less than a day
35 if: ${{ github.event_name == 'schedule' }}
36 run: test -z $(git rev-list --after="24 hours" ${{ github.sha }}) && echo "should-run=false" >> $GITHUB_OUTPUT
37
38 - name: Delete old release assets
39 if: ${{ steps.should-run.outputs.should-run != 'false' }}
40 env:
41 GH_TOKEN: ${{ github.token }}
42 run: |
43 gh release view nightly --json assets --jq '.assets[].name' | \
44 xargs -r -I {} gh release delete-asset nightly {} --yes
45
46 build-release:
47 name: build-release
48 runs-on: ${{ matrix.os }}
49 permissions:
50 contents: write
51 id-token: write
52 attestations: write
53 environment: release
54 outputs:
55 release-id: ${{ steps.release.outputs.id }}
56 strategy:
57 matrix:
58 target:
59 - x86_64-unknown-linux-musl
60 - aarch64-unknown-linux-musl
61 - x86_64-apple-darwin
62 - aarch64-apple-darwin
63 - x86_64-pc-windows-msvc
64 - aarch64-pc-windows-msvc
65 toolchain: [stable]
66 include:
67 - os: ubuntu-latest
68 target: x86_64-unknown-linux-musl
69 expected-binary-architecture: x86-64
70 cargo-tool: cross
71 - os: ubuntu-latest
72 target: aarch64-unknown-linux-musl
73 expected-binary-architecture: aarch64
74 cargo-tool: cross
75 - os: macos-15-intel
76 target: x86_64-apple-darwin
77 expected-binary-architecture: x86_64
78 cargo-tool: cargo
79 - os: macos-latest
80 target: aarch64-apple-darwin
81 expected-binary-architecture: arm64
82 cargo-tool: cargo
83 - os: windows-2022
84 target: x86_64-pc-windows-msvc
85 expected-binary-architecture: x86-64
86 cargo-tool: cargo
87 - os: windows-11-arm
88 target: aarch64-pc-windows-msvc
89 expected-binary-architecture: arm64
90 cargo-tool: cargo
91 - os: ubuntu-latest
92 target: wasm32-unknown-unknown
93 cargo-tool: wasm-pack
94 steps:
95 - name: Checkout repository
96 uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
97 with:
98 persist-credentials: false
99
100 - name: Update versions
101 shell: bash
102 run: ./bin/add-nightly-suffix-to-versions.sh
103
104 - name: "Build Archive"
105 id: build
106 uses: "./.github/actions/build-release"
107 with:
108 version: nightly
109 toolchain: ${{ matrix.toolchain }}
110 target: ${{ matrix.target }}
111 cargo-tool: ${{ matrix.cargo-tool }}
112 expected-binary-architecture: ${{ matrix.expected-binary-architecture }}
113 generate-gleam-licences-html: ${{ matrix.target == 'x86_64-unknown-linux-musl' }}
114 azure-tenant-id: ${{ secrets.AZURE_TENANT_ID }}
115 azure-subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
116 azure-client-id: ${{ secrets.AZURE_CLIENT_ID }}
117 azure-trusted-signing-account-name: ${{ vars.AZURE_TRUSTED_SIGNING_ACCOUNT_NAME }}
118 azure-certificate-profile-name: ${{ vars.AZURE_CERTIFICATE_PROFILE_NAME }}
119
120 - name: Upload release archive
121 id: release
122 uses: softprops/action-gh-release@b4309332981a82ec1c5618f44dd2e27cc8bfbfda # v3.0.0
123 with:
124 draft: false
125 prerelease: true
126 fail_on_unmatched_files: true
127 files: "${{ steps.build.outputs.files }}"
128 tag_name: nightly
129 name: "Nightly"
130 body: |
131 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.
132
133 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.
134
135 build-container-images:
136 name: build-container-images
137 needs: [prepare-nightly, build-release]
138 runs-on: ubuntu-latest
139 permissions:
140 packages: write
141 id-token: write
142 attestations: write
143 if: ${{ needs.prepare-nightly.outputs.should-run != 'false' }}
144 strategy:
145 matrix:
146 base-image:
147 - scratch
148 - erlang
149 - erlang-slim
150 - erlang-alpine
151 - elixir
152 - elixir-slim
153 - elixir-alpine
154 - node
155 - node-slim
156 - node-alpine
157
158 steps:
159 - name: Checkout repository
160 uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
161 with:
162 sparse-checkout: |
163 .github/actions
164 containers
165 persist-credentials: false
166
167 - name: "Build & Push Container"
168 uses: "./.github/actions/build-container"
169 with:
170 version: nightly
171 release-id: ${{ needs.build-release.outputs.release-id }}