Skip to content

Commit

Permalink
ci: test and release
Browse files Browse the repository at this point in the history
  • Loading branch information
m4s-b3n committed Apr 18, 2024
1 parent 5ab8bbc commit 14823ac
Show file tree
Hide file tree
Showing 5 changed files with 162 additions and 19 deletions.
22 changes: 22 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/ubuntu
{
"name": "Ubuntu",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/base:jammy",
"features": {
"ghcr.io/devcontainers/features/github-cli:1": {},
"ghcr.io/devcontainers-contrib/features/act:1": {},
"ghcr.io/devcontainers-contrib/features/actionlint:1": {}
}
// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "uname -a",
// Configure tool-specific properties.
// "customizations": {},
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for more information:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
# https://containers.dev/guide/dependabot

version: 2
updates:
- package-ecosystem: "devcontainers"
directory: "/"
schedule:
interval: weekly
40 changes: 35 additions & 5 deletions .github/workflows/test.yml → .github/workflows/test-release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test
name: Test & Release

on:
workflow_dispatch:
Expand All @@ -11,19 +11,30 @@ env:
SELECT_COMPLEX_FIELD_ID: PVTSSF_lADOCOJGKs4AX9CyzgVbXGE
SELECT_COMPLEX_OPTION_ID: 0a479792

permissions:
contents: write
issues: write
pull-requests: write

jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
show-progress: false
- uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ vars.TESTING_APP_ID }}
private-key: ${{ secrets.TESTING_APP_KEY }}
- name: Get field id
id: get-field-id
uses: ./
with:
token: ${{ secrets.PROJECT_TOKEN }}
token: ${{ steps.app-token.outputs.token }}
project-number: 1
project-owner: infinite-automations
field-name: Test Field
Expand All @@ -37,7 +48,7 @@ jobs:
id: get-select-option-id
uses: ./
with:
token: ${{ secrets.PROJECT_TOKEN }}
token: ${{ steps.app-token.outputs.token }}
project-number: 1
project-owner: infinite-automations
field-name: Test select field
Expand All @@ -52,7 +63,7 @@ jobs:
id: get-complex-select-option-id
uses: ./
with:
token: ${{ secrets.PROJECT_TOKEN }}
token: ${{ steps.app-token.outputs.token }}
project-number: 1
project-owner: infinite-automations
field-name: Test complex select field
Expand All @@ -63,4 +74,23 @@ jobs:
expected: ${{ env.SELECT_COMPLEX_OPTION_ID }}
actual: ${{ steps.get-complex-select-option-id.outputs.select-option-id }}
comparison: exact


release:
name: Release
needs:
- test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Semantic Release Plugins
run: |
npm install semantic-release-replace-plugin -D
npm install --save-dev semantic-release-major-tag
- name: Semantic Release
uses: cycjimmy/semantic-release-action@v4
with:
dry_run: ${{ github.event_name == 'pull_request' }}
ci: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59 changes: 59 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"branches": [
"main"
],
"tagFormat": "v${version}",
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/github",
[
"semantic-release-major-tag",
{
"customTags": [
"v${major}",
"v${major}.${minor}"
]
}
],
[
"semantic-release-replace-plugin",
{
"replacements": [
{
"files": [
"README.md"
],
"from": "uses: infinite-automations/gh-projects-field-ids@.*",
"to": "uses: infinite-automations/gh-projects-field-ids@v${nextRelease.version}",
"results": [
{
"file": "README.md",
"hasChanged": true,
"numMatches": 1,
"numReplacements": 1
}
],
"countMatches": true
}
]
}
],
[
"@semantic-release/changelog",
{
"changelogFile": "CHANGELOG.md"
}
],
[
"@semantic-release/git",
{
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}",
"assets": [
"CHANGELOG.md",
"README.md"
]
}
]
]
}
48 changes: 34 additions & 14 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,29 +24,49 @@ inputs:
outputs:
field-id:
description: "The id for the given field"
value: ${{ steps.get-field-id.outputs.id }}
value: ${{ steps.get-ids.outputs.field-id }}
select-option-id:
description: "The id for the given select option"
value: ${{ steps.get-select-option-id.outputs.id }}
value: ${{ steps.get-ids.outputs.select-option-id }}

runs:
using: "composite"
steps:
- name: Get field id
id: get-field-id
id: get-ids
if: ${{ inputs.field-name }}
shell: bash
env:
GH_TOKEN: ${{ inputs.token }}
run: |
field_id=$(gh project field-list ${{ inputs.project-number }} --owner "${{ inputs.project-owner }}" --format json | jq -r --arg fieldName "${{ inputs.field-name }}" '.fields[] | select(.name==$fieldName) .id')
echo "id=$field_id" >> "$GITHUB_OUTPUT"
- name: Get select option id
id: get-select-option-id
if: ${{ inputs.select-option-name }}
shell: bash
env:
GH_TOKEN: ${{ inputs.token }}
run: |
field_id=$(gh project field-list ${{ inputs.project-number }} --owner "${{ inputs.project-owner }}" --format json | jq -r --arg fieldName "${{ inputs.field-name }}" --arg selectOptionName "${{ inputs.select-option-name }}" '.fields[] | select(.name==$fieldName) .options[] | select(.name==$selectOptionName) .id')
echo "id=$field_id" >> "$GITHUB_OUTPUT"
JSON=$(\
gh project field-list ${{ inputs.project-number }} \
--owner "${{ inputs.project-owner }}" \
--format json \
)
echo JSON:
echo $JSON
echo
FIELD_ID=$(\
echo "$JSON" \
| jq -r \
--arg fieldName "${{ inputs.field-name }}" \
'.fields[] | select(.name=="$fieldName") .id' \
)
echo FIELD_ID:
echo $FIELD_ID
echo
echo "field-id=$FIELD_ID" >> "$GITHUB_OUTPUT"
SELECTION_OPTION_ID=$(\
echo "$JSON" \
| jq -r \
--arg fieldName "${{ inputs.field-name }}" \
--arg selectOptionName "${{ inputs.select-option-name }}" \
'.fields[] | select(.name=="$fieldName") .options[] | select(.name=="$selectOptionName") .id' \
)
echo SELECTION_OPTION_ID:
echo $SELECTION_OPTION_ID
echo
echo "select-option-id=$SELECTION_OPTION_ID" >> "$GITHUB_OUTPUT"

0 comments on commit 14823ac

Please sign in to comment.