Skip to content

Commit edfd52b

Browse files
committed
Work on a new release
1 parent e86c264 commit edfd52b

6 files changed

Lines changed: 71 additions & 27 deletions

File tree

.gitattributes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
* text=auto eol=lf
2+
*.{cmd,[cC][mM][dD]} text eol=crlf
3+
*.{bat,[bB][aA][tT]} text eol=crlf
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# File: .github/workflows/qa.yml
2+
3+
on:
4+
release:
5+
6+
name: Publish Module to PSGallery
7+
8+
jobs:
9+
publish:
10+
runs-on: ubuntu-22.04
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v3
14+
15+
- name: Publish module
16+
uses: pcgeek86/publish-powershell-module-action@v20
17+
id: publish-module
18+
with:
19+
NuGetApiKey: ${{ secrets.PS_GALLERY_KEY }}
20+
modulePath: ./src/PSWattTime

.markdownlint.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"MD003": {"style": "setext_with_atx" }
3+
}

README.md

Lines changed: 38 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,31 @@
11
PSWattTime
22
==========
33

4-
PowerShell Module for getting PSWattTime emission data
5-
------------------------------------------------------
4+
PowerShell Module for PSWattTime emission data
5+
----------------------------------------------
66

77
[![PowerShell Module Quality Assurance](https://github.com/cloudyspells/PSWattTime/actions/workflows/qa.yml/badge.svg)](https://github.com/cloudyspells/PSWattTime/actions/workflows/qa.yml)
88

99
This PowerShell module is intended for retrieving emissions
1010
data from [WattTime](https://www.watttime.org/) for a
11-
supplied Azure Region.
11+
supplied Azure Region during resource deployments.
12+
This is a lightweight solution making use of only the limited
13+
functionality available with a free account at _WattTime_.
14+
This means the module is only able to get near-realtime
15+
emissions data and no prodictive values. This means this module is
16+
_not_ a real solution for reduced carbon deployments and -software.
17+
It _does_ however provide some nice realtime values so you can
18+
simulate the beheaviour of deployments and software based on emissions
19+
data without the cost of a paid account for such data. For example in
20+
lab- or proof of concept environments.
21+
22+
The intended use of this module is for setting the `Location` parameter
23+
on Azure IaC deployments in GitHub workflows using the included GitHub
24+
action.
25+
26+
For a real-world solution with a commercial data provider, check out
27+
the [carbon-aware-sdk](https://github.com/Green-Software-Foundation/carbon-aware-sdk)
28+
by the [Green Software Foundation](https://greensoftware.foundation/)
1229

1330
This module is supplied as-is at the moment and not (yet)
1431
published through _PSGallery_.
@@ -18,31 +35,32 @@ published through _PSGallery_.
1835
#### PowerShell Module
1936

2037
To get started with this module you will need an account on
21-
[WattTime](https://www.watttime.org/). See
38+
[WattTime](https://www.watttime.org/). See
2239
[the manual](https://www.watttime.org/api-documentation/#register-new-user)
2340
on registering an account. NOTE: You can only register via the API.
24-
Currently no GUI exists for registration.
41+
Currently no GUI exists for registration.
2542

2643
You will also need the _Az.Resources_ PowerShell Module for Azure installed
27-
and connected to your Azure account. See
28-
[the installation manual](https://learn.microsoft.com/en-us/powershell/azure/install-az-ps) for the _Az_ module for instructions.
44+
and connected to your Azure account. See
45+
[the installation manual](https://learn.microsoft.com/en-us/powershell/azure/install-az-ps)
46+
for the _Az_ module for instructions.
2947

3048

3149
Import the module from a clone of this repository:
3250

33-
```
51+
```powershell
3452
Import-Module .\src\PSWattTime
3553
```
3654

3755
Authenticate to the _WattTime_ API:
3856

39-
```
57+
```powershell
4058
$token = Get-WattTimeAuthToken -Username '<YOUR_WATTTIME_USERNAME>' -Password '<YOUR_WATTTIME_PASSWORD>'
4159
```
4260

4361
Get current percentage of energy with emissions the 'westeurope' Azure region:
4462

45-
```
63+
```powershell
4664
PS C:\> Get-WattTimeForAzureRegion -Region westeurope -AuthToken $token
4765
4866
ba : NL
@@ -56,7 +74,7 @@ region : westeurope
5674
Determine the lowest emissions for the list of northeurope,
5775
westeurope, francecentral and uksouth Azure regions:
5876

59-
```
77+
```powershell
6078
PS C:\> Get-AzureRegionWithLowestWattTime -Regions westeurope,uksouth,northeurope,francecentral -AuthToken $token
6179
6280
ba : IE
@@ -73,7 +91,7 @@ This PowerShell module also comes with a _GitHub Action_ you can use
7391
in your GitHub workflows. Again you will need a pre-existing account
7492
for _WattTime_ and an Azure CLI/PowerShell secret configured in your repo
7593

76-
**Example**
94+
##### Example
7795

7896
```yaml
7997

@@ -92,26 +110,26 @@ jobs:
92110
- name: Checkout
93111
uses: actions/checkout@v3
94112

95-
- name: Login to Az PowerShell Module
96-
uses: azure/login@v1
97-
with:
98-
creds: ${{ secrets.AZURE_CREDENTIALS }}
99-
enable-AzPSSession: true
100-
101113
- name: Get region with lowest emissions
102114
uses: cloudyspells/PSWattTime@main
103-
id: watttime_action
115+
id: watttime_action # Set step id for using output in deployment
104116
with:
105117
azure_credential: ${{ secrets.AZURE_CREDENTIALS }}
106118
watttime_username: ${{ secrets.WATTTIMEUSERNAME }}
107119
watttime_password: ${{ secrets.WATTTIMEPASSWORD }}
108120
regions: '"westeurope","northeurope","uksouth","francecentral","germanynorth"'
109121

122+
- name: Login to Az PowerShell Module
123+
uses: azure/login@v1
124+
with:
125+
creds: ${{ secrets.AZURE_CREDENTIALS }}
126+
enable-AzPSSession: true
127+
110128
- uses: azure/arm-deploy@v1
111129
name: Run Bicep deployment
112130
with:
113131
subscriptionId: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
114132
scope: subscription
115-
region: ${{ steps.watttime_action.outputs.region }}
133+
region: ${{ steps.watttime_action.outputs.region }} # The region output from PSWattTime
116134
template: src/bicep/main.bicep
117135
```

src/PSWattTime/PSWattTime.psd1

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
RootModule = 'PSWattTime.psm1'
1313

1414
# Version number of this module.
15-
ModuleVersion = '1.0.0.0'
15+
ModuleVersion = '1.0.1.0'
1616

1717
# Supported PSEditions
1818
# CompatiblePSEditions = @()
@@ -30,7 +30,7 @@ CompanyName = 'Unknown'
3030
Copyright = '(c) Roderick Bant. All rights reserved.'
3131

3232
# Description of the functionality provided by this module
33-
# Description = ''
33+
Description = 'Simple PowerShell interface getting WattTime emissions data for Azure regions'
3434

3535
# Minimum version of the PowerShell engine required by this module
3636
# PowerShellVersion = ''
@@ -95,19 +95,19 @@ PrivateData = @{
9595
PSData = @{
9696

9797
# Tags applied to this module. These help with module discovery in online galleries.
98-
# Tags = @()
98+
Tags = @('Azure','Emissions','Carbon')
9999

100100
# A URL to the license for this module.
101-
# LicenseUri = ''
101+
LicenseUri = 'https://github.com/cloudyspells/PSWattTime/blob/main/LICENSE.md'
102102

103103
# A URL to the main website for this project.
104-
# ProjectUri = ''
104+
ProjectUri = 'https://github.com/cloudyspells/PSWattTime'
105105

106106
# A URL to an icon representing this module.
107107
# IconUri = ''
108108

109109
# ReleaseNotes of this module
110-
# ReleaseNotes = ''
110+
ReleaseNotes = 'Initial PSWattTime Release'
111111

112112
# Prerelease string of this module
113113
# Prerelease = ''

src/PSWattTime/PSWattTime.psm1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ function Get-WattTimeAuthToken {
4848
The ba to query for
4949
5050
.EXAMPLE
51-
Get-WattTime -ba 'AUS-NSW' -AuthToken $authToken
51+
Get-WattTime -ba 'NL' -AuthToken $authToken
5252
#>
5353
function Get-WattTime {
5454
[CmdletBinding()]

0 commit comments

Comments
 (0)