summarylogtreecommitdiffstats
path: root/Jenkinsfile
blob: 70bcf85e8d71442a517d29a767b51d03cbc32a98 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/* groovylint-disable GStringExpressionWithinString, LineLength */
pipeline {
    agent any
    environment {
        VERSION = """${sh(
                returnStdout: true,
                script: "curl https://api.github.com/repos/micropython/micropython/releases/latest | jq -r '.tag_name' | cut -c2- | tr -d '\n'"
            )}"""
    }
    stages {
        stage('Checkout') {
            steps {
                checkout scm
            }
        }
        stage('Update PKGBUILD') {
            steps {
                sh '''
                    sed -ie "s|pkgver=.*$|pkgver=${VERSION}|g" PKGBUILD
                    rm PKGBUILDe
                '''
            }
        }
        stage('Update Checksums') {
            steps {
                sh '''
                    updpkgsums
                '''
            }
        }
        stage('Make Package') {
            steps {
                sh '''
                    makepkg -s
                '''
            }
        }
        stage('Get Changelog') {
            steps {
                sh '''
                    curl https://api.github.com/repos/micropython/micropython/releases/latest | jq -r '.body' > ChangeLog
                '''
            }
        }
        stage('Generate .SRCINFO') {
            steps {
                sh '''
                    makepkg --printsrcinfo > .SRCINFO
                '''
            }
        }
        stage('Cleanup - makepkg Artifacts') {
            steps {
                sh '''
                    rm -rf pkg src micropython-*
                '''
            }
        }
        stage('Git Push') {
            steps {
                withCredentials([sshUserPrivateKey(credentialsId: "Arch_AUR", keyFileVariable: 'KEY')]) {
                    sh '''
                        git config user.email "aman.iv0012@gmail.com"
                        git config user.name "Aman Gupta"
                        export GIT_SSH_COMMAND="ssh -o StrictHostKeyChecking=no -i $KEY"
                        git branch release
                        git checkout master
                        git merge release
                        git remote add ssh-origin ssh://aur@aur.archlinux.org/micropython.git
                        git commit -am "Automated Release: Updated to v${VERSION}"
                        git push ssh-origin master
                    '''
                }
            }
        }
    }
    post {
        always {
            deleteDir() /* clean up our workspace */
        }
        success {
            withCredentials([string(credentialsId: 'Discord_Webhook', variable: 'WEBHOOK_URL')]) {
                sh '''
                    curl -H 'Content-Type: application/json' -d '{\"content\": \"✅ Micropython v'"$VERSION"' Released to AUR 🎆\"}' ${WEBHOOK_URL}
                '''
            }
        }
        failure {
            withCredentials([string(credentialsId: 'Discord_Webhook', variable: 'WEBHOOK_URL')]) {
                sh '''
                    curl -H 'Content-Type: application/json' -d '{\"content\": \"❌ Micropython v'"$VERSION"' Pipeline Failed 🛠️\"}' ${WEBHOOK_URL}
                '''
            }
        }
    }
}