Skip to content

Commit 4408d68

Browse files
authored
Setup semantic-release (#8)
* Minor refactor to packages output * Setup semantic-release * Test release workflow * Testing release workflow from feature branch * Granting extra permissions to the injected token * Move release steps to a separate workflow * Rename CI workflow to Build * Update status badges * Remove extra line * Update semantic-release config * Testing release workflow * Revert "Testing release workflow" This reverts commit 84935b6. * Update README * Fix status badge * Disable commenting on issues and pull requests * Only push to Cachix from the default branch * Increase timeout for templates * Limit release workflow to main branch only * Add missing permissions to release workflow
1 parent 6d7fff4 commit 4408d68

File tree

8 files changed

+5746
-14
lines changed

8 files changed

+5746
-14
lines changed

.github/workflows/ci.yml .github/workflows/build.yml

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
name: CI
1+
name: Build
22

33
on: push
44

55
concurrency:
6-
group: ci-${{ github.ref }}
6+
group: build-${{ github.ref }}
77
cancel-in-progress: true
88

99
jobs:
@@ -22,6 +22,7 @@ jobs:
2222
with:
2323
name: nixpkgs-terraform
2424
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
25+
skipPush: ${{ github.ref_name != 'main' }}
2526
- name: Build all packages
2627
run: nix flake check --impure
2728
env:
@@ -33,7 +34,7 @@ jobs:
3334
template: [default, devenv]
3435
fail-fast: true
3536
runs-on: ubuntu-latest
36-
timeout-minutes: 2
37+
timeout-minutes: 4
3738
needs: [build]
3839
steps:
3940
- name: Checkout code

.github/workflows/release.yml

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Release
2+
3+
on:
4+
workflow_run:
5+
workflows: [Build]
6+
types: [completed]
7+
branches: [main]
8+
9+
concurrency:
10+
group: release
11+
cancel-in-progress: true
12+
13+
jobs:
14+
release:
15+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
16+
runs-on: ubuntu-latest
17+
permissions:
18+
contents: write
19+
issues: write
20+
pull-requests: write
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v4
24+
- name: Install Nix
25+
uses: DeterminateSystems/nix-installer-action@v6
26+
- name: Install tools via Nix
27+
run: nix develop --check
28+
- name: Install dependencies
29+
run: nix develop -c npm ci
30+
- name: Run semantic-release
31+
run: nix develop -c npx semantic-release
32+
env:
33+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.direnv
22
.env
3+
node_modules
34
result
45
templates/*/flake.lock

.releaserc.yml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
branches: [main]
2+
plugins:
3+
- "@semantic-release/commit-analyzer"
4+
- "@semantic-release/release-notes-generator"
5+
- ["@semantic-release/github", { successComment: false }]

README.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# nixpkgs-terraform
22

3-
[![CI](https://github.com/stackbuilders/nixpkgs-terraform/actions/workflows/ci.yml/badge.svg)](https://github.com/stackbuilders/nixpkgs-terraform/actions/workflows/ci.yml)
3+
[![Build](https://github.com/stackbuilders/nixpkgs-terraform/actions/workflows/build.yml/badge.svg)](https://github.com/stackbuilders/nixpkgs-terraform/actions/workflows/build.yml)
44
[![Update](https://github.com/stackbuilders/nixpkgs-terraform/actions/workflows/update.yml/badge.svg)](https://github.com/stackbuilders/nixpkgs-terraform/actions/workflows/update.yml)
5+
[![Release](https://github.com/stackbuilders/nixpkgs-terraform/actions/workflows/release.yml/badge.svg)](https://github.com/stackbuilders/nixpkgs-terraform/actions/workflows/release.yml)
56

67
A collection of Terraform versions that are automatically updated.
78

@@ -123,10 +124,17 @@ Do you want to contribute to this project? Please take a look at our
123124
[contributing guideline](docs/CONTRIBUTING.md) to know how you can help us
124125
build it.
125126

127+
Aside from the contribution guidelines outlined above, this project uses
128+
[semantic-release] to automate version management; thus, we encourage
129+
contributors to follow the commit conventions outlined
130+
[here](https://semantic-release.gitbook.io/semantic-release/#commit-message-format)
131+
to make it easier for maintainers to release new changes.
132+
126133
---
127134
<img src="https://www.stackbuilders.com/media/images/Sb-supports.original.png"
128135
alt="Stack Builders" width="50%"></img>
129136
[Check out our libraries](https://github.com/stackbuilders/) | [Join our
130137
team](https://www.stackbuilders.com/join-us/)
131138

132139
[nix-shell]: https://nixos.wiki/wiki/Development_environment_with_nix-shell
140+
[semantic-release]: https://semantic-release.gitbook.io/semantic-release/

flake.nix

+6-10
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,16 @@
2626
])
2727
)
2828
pkgs-unstable.nix-prefetch
29+
pkgs.nodejs
2930
];
3031
};
3132
# https://github.com/NixOS/nix/issues/7165
3233
checks = self.packages.${system};
33-
packages = builtins.listToAttrs
34-
(builtins.map
35-
(version: {
36-
name = version;
37-
value = self.lib.buildTerraform {
38-
inherit system version;
39-
inherit (versions.${version}) hash vendorHash;
40-
};
41-
})
42-
(builtins.attrNames versions));
34+
packages = builtins.mapAttrs
35+
(version: { hash, vendorHash }: self.lib.buildTerraform {
36+
inherit system version hash vendorHash;
37+
})
38+
versions;
4339
}) // {
4440
lib.buildTerraform = { system, version, hash, vendorHash }:
4541
let

0 commit comments

Comments
 (0)